Kagome
Polkadot Runtime Engine in C++17
|
#include <connection.hpp>
Public Types | |
using | OnConnectedCallback = std::function< void(std::shared_ptr< TelemetryConnection >)> |
Public Member Functions | |
virtual | ~TelemetryConnection ()=default |
virtual void | connect ()=0 |
virtual const TelemetryEndpoint & | endpoint () const =0 |
Returns the associated telemetry endpoint. More... | |
virtual void | send (const std::string &data)=0 |
virtual void | send (std::size_t message_handle)=0 |
virtual bool | isConnected () const =0 |
Get the current status of the connection. More... | |
virtual void | shutdown ()=0 |
Request the connection to shutdown. More... | |
Represents a connection to the single telemetry server.
The target URI and OnConnectedCallback are to be passed to the implementation class' constructor.
Definition at line 23 of file connection.hpp.
using kagome::telemetry::TelemetryConnection::OnConnectedCallback = std::function<void(std::shared_ptr<TelemetryConnection>)> |
The callback to be called each time the connection (re-)establishes.
Can be called multiple times even after a single call of connect() due to losing connection and reconnecting to the backend server.
The callback is used to let the TelemetryService send the greeting message.
Definition at line 35 of file connection.hpp.
|
virtualdefault |
|
pure virtual |
Initiates attempts to connect.
Designed to be called only once by the TelemetryService.
Implemented in kagome::telemetry::TelemetryConnectionImpl.
|
pure virtual |
Returns the associated telemetry endpoint.
Implemented in kagome::telemetry::TelemetryConnectionImpl.
|
pure virtual |
Get the current status of the connection.
Implemented in kagome::telemetry::TelemetryConnectionImpl.
|
pure virtual |
Write the data to the websocket if connected
data | - the data line to send |
The data might be disposed in an outer scope as soon as the method returns.
Implemented in kagome::telemetry::TelemetryConnectionImpl.
|
pure virtual |
Write the message pointed by a message handle.
message_handle | - message to serve |
TelemetryConnection and TelemetryService are tightly related and shares a common message pool to avoid redundant memory consumption. That is why TelemetryService schedules messages to the pool and passes only handles to connections. It is connection's duty to release a message from the pool when send/write operation completes.
Implemented in kagome::telemetry::TelemetryConnectionImpl.
|
pure virtual |
Request the connection to shutdown.
Implemented in kagome::telemetry::TelemetryConnectionImpl.