Peer to Peer server functionality. More...
#include <p2pserver.hpp>
Public Member Functions | |
void | disconnectAll () |
Disconnects all connected peers. | |
void | enableVerboseLogging (bool enable) |
Controls verbose logging. | |
void | flushPendingProviders () |
Refresh updates pending for transfer credits. | |
ClientIdManager & | getClientIdManager () const |
Retrieve client id manager functionality. | |
ConnectDomainSharedPtr | getConnectDomain () const |
Retrieve connect domain. | |
string | getDiagnosticsCounters (vector< DiagnosticsObject > &objects) |
Will fill the provided array with known diagnostics variables. | |
vector< EndpointSharedPtr > | getEndpoints () |
Gets all the endpoints this P2PServer has configured. | |
RoutingRulesSharedPtr | getRoutingRules () |
Retrieve routing rules for the bound service. | |
bool | initialize (RoutingRules &rr, ConnectionAdapter::Parameters SSLParameters=ConnectionAdapter::Parameters()) |
Initialize and instantiate all required connection adapters. | |
P2PServer (ClientIdManager &cim, const string &reliableBearer, const string &unreliableBearer, ConnectDomainSharedPtr domain, AbstractServiceSharedPtr service, RuntimeDataProvider *dataProvider) | |
Constructor. | |
void | registerMessageFilter (messagefilter::ServiceMessageFilterHandler handler) |
Register a message filter callback that is invoked for each and every incoming message. | |
void | reportServiceRuntimeData (const string &interfaceId, const string &path, const string &stream) |
Invoked when-ever the runtime data of the hosted remote service changes. | |
void | setDomain (ConnectDomainSharedPtr domain) |
Sets the domain to be used. | |
bool | transmit (size_t clientId, const MessagePackage &message) |
Transmits a provided message to specified client. | |
bool | tryTransmitDirectly (const MessagePackage &message) |
Try transmit message directly to peers shall there be a route(s) for such. | |
virtual | ~P2PServer () |
Destructor. | |
![]() | |
virtual | ~Observer ()=default |
Protected Member Functions | |
virtual void | onConnected (int clientId, NetworkListener *listener) override |
Callback to notify that connection has been established. | |
virtual void | onDisconnected (int clientId, NetworkListener *listener) override |
Callback to notify that connection has been terminated. | |
virtual void | onPacketReceived (int clientId, NetworkListener *listener) override |
Callback to notify that there is incoming data. | |
Peer to Peer server functionality.
|
explicit |
Constructor.
cim | client identity manager |
reliableBearer | the default bearer for reliable communication |
unreliableBearer | the default bearer for unreliable communication |
domain | server side connect domain |
service | the service bound to this P2P functionality |
dataProvider | runtime data provider. |
|
virtual |
Destructor.
void kanzi::connect::p2p::P2PServer::disconnectAll | ( | ) |
Disconnects all connected peers.
void kanzi::connect::p2p::P2PServer::enableVerboseLogging | ( | bool | enable | ) |
Controls verbose logging.
enable | enables the verbose logging. |
void kanzi::connect::p2p::P2PServer::flushPendingProviders | ( | ) |
Refresh updates pending for transfer credits.
ClientIdManager & kanzi::connect::p2p::P2PServer::getClientIdManager | ( | ) | const |
Retrieve client id manager functionality.
ConnectDomainSharedPtr kanzi::connect::p2p::P2PServer::getConnectDomain | ( | ) | const |
Retrieve connect domain.
string kanzi::connect::p2p::P2PServer::getDiagnosticsCounters | ( | vector< DiagnosticsObject > & | objects | ) |
Will fill the provided array with known diagnostics variables.
objects | vector to be filled with diagnostics objects. |
vector< EndpointSharedPtr > kanzi::connect::p2p::P2PServer::getEndpoints | ( | ) |
Gets all the endpoints this P2PServer has configured.
RoutingRulesSharedPtr kanzi::connect::p2p::P2PServer::getRoutingRules | ( | ) |
Retrieve routing rules for the bound service.
bool kanzi::connect::p2p::P2PServer::initialize | ( | RoutingRules & | rr, |
ConnectionAdapter::Parameters | SSLParameters = ConnectionAdapter::Parameters() ) |
Initialize and instantiate all required connection adapters.
rr | routing rules that will be filled with connection endpoints accordingly. |
SSLParameters | contains SSL parameters to be used with server side functionality. Required only if SSL bearer is to be used. Parameters should be passed with following keys "server_cert" Server certificate "server_pkey" Server private key "client_ca" Client CA certificate. "server_name" server name identitity (optional) |
|
overrideprotectedvirtual |
Callback to notify that connection has been established.
clientId | The id of the connected client. |
listener | Listener that triggered the notification. |
Reimplemented from kanzi::connect::NetworkListener::Observer.
|
overrideprotectedvirtual |
Callback to notify that connection has been terminated.
clientId | The id of the disconnected client. |
listener | Listener that triggered the notification. |
Reimplemented from kanzi::connect::NetworkListener::Observer.
|
overrideprotectedvirtual |
Callback to notify that there is incoming data.
clientId | The id of the client that sent data. |
listener | Listener that triggered the notification. |
Reimplemented from kanzi::connect::NetworkListener::Observer.
void kanzi::connect::p2p::P2PServer::registerMessageFilter | ( | messagefilter::ServiceMessageFilterHandler | handler | ) |
Register a message filter callback that is invoked for each and every incoming message.
handler | the handler to be invoked. |
void kanzi::connect::p2p::P2PServer::reportServiceRuntimeData | ( | const string & | interfaceId, |
const string & | path, | ||
const string & | stream ) |
Invoked when-ever the runtime data of the hosted remote service changes.
interfaceId | the interface whom data got changed |
path | the path that got changed. |
stream | the serialized runtimedata stream. |
void kanzi::connect::p2p::P2PServer::setDomain | ( | ConnectDomainSharedPtr | domain | ) |
Sets the domain to be used.
domain | the domain |
bool kanzi::connect::p2p::P2PServer::transmit | ( | size_t | clientId, |
const MessagePackage & | message ) |
Transmits a provided message to specified client.
clientId | the client to dispatch the message to |
message | the message to dispatch |
bool kanzi::connect::p2p::P2PServer::tryTransmitDirectly | ( | const MessagePackage & | message | ) |
Try transmit message directly to peers shall there be a route(s) for such.
message | the message to send |