Class to facade a network listener client and message dispatching. More...
#include <p2pclient.hpp>
Public Types | |
enum | State { StateDisconnected , StateConnecting , StateConnected , StateWaitingReconnect } |
Public Member Functions | |
void | addStateChangeCallback (ConnectionStateChangedFunctionType callback) |
Insert callback to listen to registration changes. | |
bool | canHandleEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) |
Checks whether this paritucular network listener can handle the particular endpoint. | |
size_t | countEndpoints () const |
Return amount of endpoints the class has. | |
void | enableVerboseLogging (bool enable) |
Controls logging verbosity. | |
void | insertEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) |
Inserts a new endpoint. | |
bool | isConnected () const |
Connection state retrieval. | |
bool | isDisconnected () const |
Connection state retrieval. | |
NetworkListenerRegistration (NetworkListenerClientSharedPtr networkListener, ClientSharedPtr client, int serverclientid, bool verboseLogging) | |
Constructor. | |
virtual void | onConnected () override |
Listener thread has established connection to server. | |
virtual void | onDisconnected () override |
Listener thread has terminated connection from server. | |
virtual void | onFailedToConnect () override |
Listener thread failed to connect. | |
virtual void | onReceive () override |
Listener thread received data. | |
bool | refersToEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) const |
Checks whether this registration refers to a specified endpoint. | |
bool | removeEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) |
Removes a endpoint. | |
bool | startConnect () |
Starts connection establishment. | |
void | stop () |
Stops the operation including the worker thread. | |
string | toString () |
Get stringular representation of the network connection. | |
bool | unreliableLink () |
Describe the link type whether it is reliable or unreliable. | |
void | work () |
To be invoked to process incoming messages from the network listener. | |
~NetworkListenerRegistration () | |
Destructor. | |
![]() | |
virtual | ~Observer ()=default |
![]() | |
virtual bool | getParameter (size_t id, size_t ¶m) |
Allows to retrieve a dispatcher specific parameter, mostly for internal use. | |
MessageDispatcher () | |
Constructor. | |
virtual | ~MessageDispatcher () |
Destructor. | |
Protected Member Functions | |
virtual void | dispatch (const MessagePackage &message) override |
Dispatches this message to its destination. | |
string | stateToString (State state) |
Converts a state to its stringular expression. | |
void | toState (State state) |
Transfers to provided state. | |
Class to facade a network listener client and message dispatching.
kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::NetworkListenerRegistration | ( | NetworkListenerClientSharedPtr | networkListener, |
ClientSharedPtr | client, | ||
int | serverclientid, | ||
bool | verboseLogging ) |
Constructor.
networkListener | The listener that this registration represents. |
client | Client instance. Ownerhip is not transfered. |
serverclientid | The identifier number that this client has on a server. |
verboseLogging | When set to true, the information is printed in verbose manner. |
kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::~NetworkListenerRegistration | ( | ) |
Destructor.
|
inline |
Insert callback to listen to registration changes.
callback | The method to invoke for changes. You can set only one callback. |
bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::canHandleEndpoint | ( | shared_ptr< p2p::RoutingRules::Endpoint > | endpoint | ) |
Checks whether this paritucular network listener can handle the particular endpoint.
endpoint | the endpoint to check. |
size_t kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::countEndpoints | ( | ) | const |
Return amount of endpoints the class has.
|
overrideprotectedvirtual |
Dispatches this message to its destination.
message | Message to dispatch. |
Implements kanzi::connect::MessageDispatcher.
|
inline |
Controls logging verbosity.
enable | true to enable verbose logging from the class. |
void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::insertEndpoint | ( | shared_ptr< p2p::RoutingRules::Endpoint > | endpoint | ) |
Inserts a new endpoint.
endpoint | the endpoint to insert |
|
inline |
Connection state retrieval.
|
inline |
Connection state retrieval.
|
overridevirtual |
Listener thread has established connection to server.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
|
overridevirtual |
Listener thread has terminated connection from server.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
|
overridevirtual |
Listener thread failed to connect.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
|
overridevirtual |
Listener thread received data.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::refersToEndpoint | ( | shared_ptr< p2p::RoutingRules::Endpoint > | endpoint | ) | const |
Checks whether this registration refers to a specified endpoint.
endpoint | the endpoint to check |
bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::removeEndpoint | ( | shared_ptr< p2p::RoutingRules::Endpoint > | endpoint | ) |
Removes a endpoint.
endpoint | the endpoint to remove. |
bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::startConnect | ( | ) |
Starts connection establishment.
|
protected |
Converts a state to its stringular expression.
state | the state |
void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::stop | ( | ) |
Stops the operation including the worker thread.
|
protected |
Transfers to provided state.
state | the state to transfer to. |
string kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::toString | ( | ) |
Get stringular representation of the network connection.
mainly for debugging purposes
bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::unreliableLink | ( | ) |
Describe the link type whether it is reliable or unreliable.
By default, all the links are assumed to be reliable unless otherwise explicitly stated by the network adapter
void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::work | ( | ) |
To be invoked to process incoming messages from the network listener.