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. More... | |
| bool | canHandleEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) |
| Checks whether this paritucular network listener can handle the particular endpoint. More... | |
| size_t | countEndpoints () const |
| Return amount of endpoints the class has. More... | |
| void | enableVerboseLogging (bool enable) |
| Controls logging verbosity. More... | |
| void | insertEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) |
| Inserts a new endpoint. More... | |
| bool | isConnected () const |
| Connection state retrieval. More... | |
| bool | isDisconnected () const |
| Connection state retrieval. More... | |
| NetworkListenerRegistration (NetworkListenerClientSharedPtr networkListener, ClientSharedPtr client, int serverclientid, bool verboseLogging) | |
| Constructor. More... | |
| virtual void | onConnected () KZ_OVERRIDE |
| Listener thread has established connection to server. More... | |
| virtual void | onDisconnected () KZ_OVERRIDE |
| Listener thread has terminated connection from server. More... | |
| virtual void | onFailedToConnect () KZ_OVERRIDE |
| Listener thread failed to connect. More... | |
| virtual void | onReceive () KZ_OVERRIDE |
| Listener thread received data. More... | |
| bool | refersToEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) const |
| Checks whether this registration refers to a specified endpoint. More... | |
| bool | removeEndpoint (shared_ptr< p2p::RoutingRules::Endpoint > endpoint) |
| Removes a endpoint. More... | |
| bool | startConnect () |
| Starts connection establishment. More... | |
| void | stop () |
| Stops the operation including the worker thread. More... | |
| string | toString () |
| Get stringular representation of the network connection. More... | |
| bool | unreliableLink () |
| Describe the link type whether it is reliable or unreliable. More... | |
| void | work () |
| To be invoked to process incoming messages from the network listener. More... | |
| ~NetworkListenerRegistration () | |
| Destructor. More... | |
Public Member Functions inherited from kanzi::connect::MessageDispatcher | |
| virtual bool | getParameter (size_t, size_t &) |
| Allows to retrieve a dispatcher specific parameter, mostly for internal use. More... | |
| MessageDispatcher () | |
| Constructor. More... | |
| virtual | ~MessageDispatcher () |
| Destructor. More... | |
Protected Member Functions | |
| virtual void | dispatch (const MessagePackage &message) KZ_OVERRIDE |
| Dispatches this message to its destination. More... | |
| string | stateToString (State state) |
| Converts a state to its stringular expression. More... | |
| void | toState (State state) |
| Transfers to provided state. More... | |
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.
|
protectedvirtual |
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.
|
virtual |
Listener thread has established connection to server.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
|
virtual |
Listener thread has terminated connection from server.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
|
virtual |
Listener thread failed to connect.
Reimplemented from kanzi::connect::NetworkListenerClient::Observer.
|
virtual |
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.