Kagome
Polkadot Runtime Engine in C++17
kagome::telemetry::TelemetryConnection Class Referenceabstract

#include <connection.hpp>

Inheritance diagram for kagome::telemetry::TelemetryConnection:
Collaboration diagram for kagome::telemetry::TelemetryConnection:

Public Types

using OnConnectedCallback = std::function< void(std::shared_ptr< TelemetryConnection >)>
 

Public Member Functions

virtual ~TelemetryConnection ()=default
 
virtual void connect ()=0
 
virtual const TelemetryEndpointendpoint () 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...
 

Detailed Description

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.

Member Typedef Documentation

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.

Constructor & Destructor Documentation

virtual kagome::telemetry::TelemetryConnection::~TelemetryConnection ( )
virtualdefault

Member Function Documentation

virtual void kagome::telemetry::TelemetryConnection::connect ( )
pure virtual

Initiates attempts to connect.

Designed to be called only once by the TelemetryService.

Implemented in kagome::telemetry::TelemetryConnectionImpl.

virtual const TelemetryEndpoint& kagome::telemetry::TelemetryConnection::endpoint ( ) const
pure virtual

Returns the associated telemetry endpoint.

Implemented in kagome::telemetry::TelemetryConnectionImpl.

virtual bool kagome::telemetry::TelemetryConnection::isConnected ( ) const
pure virtual

Get the current status of the connection.

Implemented in kagome::telemetry::TelemetryConnectionImpl.

virtual void kagome::telemetry::TelemetryConnection::send ( const std::string &  data)
pure virtual

Write the data to the websocket if connected

Parameters
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.

virtual void kagome::telemetry::TelemetryConnection::send ( std::size_t  message_handle)
pure virtual

Write the message pointed by a message handle.

Parameters
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.

virtual void kagome::telemetry::TelemetryConnection::shutdown ( )
pure virtual

Request the connection to shutdown.

Implemented in kagome::telemetry::TelemetryConnectionImpl.


The documentation for this class was generated from the following file: