p2p::P2PClient¶
-
class
kanzi::connect::p2p
::
P2PClient
: public ConnectionAdapterProvider¶ Client side handler for P2P client connections.
Public Types
-
typedef function<void(P2PClient::NetworkListenerRegistration*, bool)>
ConnectionStateChangedFunctionType
¶
-
typedef shared_ptr<void>
ConnectionStateSubscriptionToken
¶
Public Functions
Constructor.
- Parameters
client
: client instance this P2P connection adapter is bound to
-
~P2PClient
()¶ Destructor.
Installs a routing handler.
- Parameters
handler
: the routing handler to installcontext
: installation context for debug purposes.runtimeDataOnly
: if true, then route is handled only for runtimedata
-
ConnectionStateSubscriptionToken
addStateChangeSubscription
(ConnectionStateChangedFunctionType callback)¶ Register a state change callback.
- Return
subscription handle that can be used to unregister.
- Parameters
callback
: the function to register
-
void
disconnectAll
()¶ Disconnects unconditionally all existing connections.
-
ClientSharedPtr
getClient
() const¶ Retrieve a client object bound to this P2P client instance.
- Return
Pointer to client instance. ownership not transfered.
Gets network listener that is bound to this specific session.
- Return
network registration object or empty
- Parameters
session
: the session where the listener is bound to
Remove existing routing handler.
- Parameters
session
: the kanzi connect session bound to routing handler that need to be removedcontext
: removal context for debug purposes.
-
void
removeStateChangeSubscription
(ConnectionStateSubscriptionToken token)¶ Unregisters a state change callback.
- Parameters
token
: the registration token to unregister.
-
void
work
()¶ To be invoked when required from the application main thread context.
purges incoming messages.
-
class
NetworkListenerRegistration
: public NetworkListenerClient::Observer, public MessageDispatcher¶ Class to facade a network listener client and message dispatching.
Public Types
Public Functions
Constructor.
- Parameters
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.
-
~NetworkListenerRegistration
()¶ Destructor.
-
void
addStateChangeCallback
(ConnectionStateChangedFunctionType callback)¶ Insert callback to listen to registration changes.
- Parameters
callback
: The method to invoke for changes. You can set only one callback.
Checks whether this paritucular network listener can handle the particular endpoint.
- Return
true if this listener can handle provided endpoint
- Parameters
endpoint
: the endpoint to check.
-
size_t
countEndpoints
() const¶ Return amount of endpoints the class has.
- Return
amount of endpoints
-
void
enableVerboseLogging
(bool enable)¶ Controls logging verbosity.
- Parameters
enable
: true to enable verbose logging from the class.
Inserts a new endpoint.
- Parameters
endpoint
: the endpoint to insert
-
bool
isConnected
() const¶ Connection state retrieval.
- Return
true if connected currently.
-
bool
isDisconnected
() const¶ Connection state retrieval.
- Return
true if disconnected currently.
-
void
onConnected
() override¶ Listener thread has established connection to server.
-
void
onDisconnected
() override¶ Listener thread has terminated connection from server.
-
void
onFailedToConnect
() override¶ Listener thread failed to connect.
-
void
onReceive
() override¶ Listener thread received data.
Checks whether this registration refers to a specified endpoint.
- Return
true if refers to endpoint.
- Parameters
endpoint
: the endpoint to check
Removes a endpoint.
- Return
true if endpoint was referenced and got removed.
- Parameters
endpoint
: the endpoint to remove.
-
bool
startConnect
()¶ Starts connection establishment.
- Return
true if successfully started.
-
void
stop
()¶ Stops the operation including the worker thread.
-
string
toString
()¶ Get stringular representation of the network connection.
mainly for debugging purposes
- Return
stringular representation of the network connection.
-
bool
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
- Return
true if link is considered unreliable.
-
void
work
()¶ To be invoked to process incoming messages from the network listener.
-
class
RoutingHandler
¶ Map a stringular identifier (that being a service session or potentially a runtime data subscription or whatever)
Public Functions
-
const string
getInterface
() const¶ Retrieve interface.
- Return
interface
-
shared_ptr<RoutingRules>
getRules
()¶ Retrieve routing rules.
- Return
routing rules.
-
AbstractSessionSharedPtr
getSession
()¶ Retrieve session.
- Return
session
Public Static Functions
Factory method to create instance of routing handler.
- Parameters
routingRules
: routing rule objectsession
: communication session bound to the routing rulesuri
: optional uri
-
const string
-
typedef function<void(P2PClient::NetworkListenerRegistration*, bool)>