Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::p2p::P2PClient::NetworkListenerRegistration Class Reference

Class to facade a network listener client and message dispatching. More...

#include <p2pclient.hpp>

Inheritance diagram for kanzi::connect::p2p::P2PClient::NetworkListenerRegistration:
kanzi::connect::NetworkListenerClient::Observer kanzi::connect::MessageDispatcher

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

Detailed Description

Class to facade a network listener client and message dispatching.

Member Enumeration Documentation

◆ State

Enumerator
StateDisconnected 

Disconnected.

StateConnecting 

Connecting started but not yet established.

StateConnected 

Connected.

StateWaitingReconnect 

After unsuccesfull connect a wait state after which next reconnect attempt is made.

Constructor & Destructor Documentation

◆ NetworkListenerRegistration()

kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::NetworkListenerRegistration ( NetworkListenerClientSharedPtr  networkListener,
ClientSharedPtr  client,
int  serverclientid,
bool  verboseLogging 
)

Constructor.

Parameters
networkListenerThe listener that this registration represents.
clientClient instance. Ownerhip is not transfered.
serverclientidThe identifier number that this client has on a server.
verboseLoggingWhen set to true, the information is printed in verbose manner.

◆ ~NetworkListenerRegistration()

kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::~NetworkListenerRegistration ( )

Destructor.

Member Function Documentation

◆ addStateChangeCallback()

void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::addStateChangeCallback ( ConnectionStateChangedFunctionType  callback)
inline

Insert callback to listen to registration changes.

Parameters
callbackThe method to invoke for changes. You can set only one callback.

◆ canHandleEndpoint()

bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::canHandleEndpoint ( shared_ptr< p2p::RoutingRules::Endpoint endpoint)

Checks whether this paritucular network listener can handle the particular endpoint.

Parameters
endpointthe endpoint to check.
Returns
true if this listener can handle provided endpoint

◆ countEndpoints()

size_t kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::countEndpoints ( ) const

Return amount of endpoints the class has.

Returns
amount of endpoints

◆ dispatch()

virtual void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::dispatch ( const MessagePackage message)
protectedvirtual

Dispatches this message to its destination.

Parameters
messageMessage to dispatch.

Implements kanzi::connect::MessageDispatcher.

◆ enableVerboseLogging()

void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::enableVerboseLogging ( bool  enable)
inline

Controls logging verbosity.

Parameters
enabletrue to enable verbose logging from the class.

◆ insertEndpoint()

void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::insertEndpoint ( shared_ptr< p2p::RoutingRules::Endpoint endpoint)

Inserts a new endpoint.

Parameters
endpointthe endpoint to insert

◆ isConnected()

bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::isConnected ( ) const
inline

Connection state retrieval.

Returns
true if connected currently.

◆ isDisconnected()

bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::isDisconnected ( ) const
inline

Connection state retrieval.

Returns
true if disconnected currently.

◆ onConnected()

virtual void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::onConnected ( )
virtual

Listener thread has established connection to server.

Reimplemented from kanzi::connect::NetworkListenerClient::Observer.

◆ onDisconnected()

virtual void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::onDisconnected ( )
virtual

Listener thread has terminated connection from server.

Reimplemented from kanzi::connect::NetworkListenerClient::Observer.

◆ onFailedToConnect()

virtual void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::onFailedToConnect ( )
virtual

Listener thread failed to connect.

Reimplemented from kanzi::connect::NetworkListenerClient::Observer.

◆ onReceive()

virtual void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::onReceive ( )
virtual

Listener thread received data.

Reimplemented from kanzi::connect::NetworkListenerClient::Observer.

◆ refersToEndpoint()

bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::refersToEndpoint ( shared_ptr< p2p::RoutingRules::Endpoint endpoint) const

Checks whether this registration refers to a specified endpoint.

Parameters
endpointthe endpoint to check
Returns
true if refers to endpoint.

◆ removeEndpoint()

bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::removeEndpoint ( shared_ptr< p2p::RoutingRules::Endpoint endpoint)

Removes a endpoint.

Parameters
endpointthe endpoint to remove.
Returns
true if endpoint was referenced and got removed.

◆ startConnect()

bool kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::startConnect ( )

Starts connection establishment.

Returns
true if successfully started.

◆ stateToString()

string kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::stateToString ( State  state)
protected

Converts a state to its stringular expression.

Parameters
statethe state
Returns
name of the state

◆ stop()

void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::stop ( )

Stops the operation including the worker thread.

◆ toState()

void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::toState ( State  state)
protected

Transfers to provided state.

Parameters
statethe state to transfer to.

◆ toString()

string kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::toString ( )

Get stringular representation of the network connection.

mainly for debugging purposes

Returns
stringular representation of the network connection.

◆ unreliableLink()

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

Returns
true if link is considered unreliable.

◆ work()

void kanzi::connect::p2p::P2PClient::NetworkListenerRegistration::work ( )

To be invoked to process incoming messages from the network listener.


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