A class that is used to deliver interface network messages between client and server. More...
#include <abstract_session.hpp>
Public Types | |
| typedef function< bool(const MessagePackage &message)> | MessageReceivedFunction |
| Message subscription callback. More... | |
| typedef shared_ptr< void > | MessageSubscriptionToken |
| typedef unordered_map< string, string > | ServiceAttributes |
Public Member Functions | |
| AbstractSession (const string &interfaceId, int clientId, int sessionId, MessageDispatcher *dispatcher) | |
| Constructor. More... | |
| MessageSubscriptionToken | addMessageSubscription (const string &messageType, MessageReceivedFunction function) |
| Subscribe all messages of type. More... | |
| void | changeMessageDispatcher (MessageDispatcher *dispatcher) |
| Changes message dispatcher on the fly. More... | |
| void | enableVerboseLogging (bool enable) |
| Enables verbose logging for the functionality. More... | |
| ClientDescriptorSharedPtr | getClientDescriptor () const |
| Retrieve client descriptor. More... | |
| int | getClientId () const |
| Retrieve client id of the session. More... | |
| int | getId () const |
| Retrieve id of the session. More... | |
| const string & | getInterfaceId () const |
| Retrieve id of the interface. More... | |
| int | getServerClientId () const |
| Retrieve server client identifier of the session. More... | |
| const ServiceAttributes & | getServiceAttributes () |
| virtual void | initialize () |
| Initializes this session. More... | |
| void | receive (const MessagePackage &message) |
| Asks session to process received message. More... | |
| void | removeMessageSubscription (const string &messageType, MessageSubscriptionToken token) |
| Remove message subscription. More... | |
| void | setClientDescriptor (ClientDescriptorSharedPtr clientDescriptor) |
| Saves a client descriptor of the client who created this session. More... | |
| void | setClientP2PRoutingInstructions (shared_ptr< p2p::P2PClient::RoutingHandler > routingHandler) |
| Configure P2P routing instructions for the client. More... | |
| void | setGenericInvoker (GenericInvoker *invoker) |
| Setups generic invocation mechanism. More... | |
| void | setServerClientId (int id) |
| Sets servers identifier of the client this session belongs to. More... | |
| void | setServerP2PRouter (p2p::P2PServerSharedPtr serverRouter) |
| Configure P2P routing for server scope. More... | |
| void | terminate () |
| Terminates the session. More... | |
| bool | transmit (const MessagePackage &message) |
| Sends outgoing message to network. More... | |
| bool | transmit (MessagePackageSharedPtr message, uint32_t call_handle=0) |
| Sends outgoing message to network. More... | |
| virtual void | uninitialize () |
| Un-initializes this session. More... | |
| void | updateEnabledState (bool newEnabledState) |
| Update the enabled state of this session. More... | |
| virtual | ~AbstractSession () |
| Destructor. More... | |
Protected Member Functions | |
| virtual shared_ptr< GenericRPCReplyMessage > | onReceiveMessage (const MessagePackage &message) |
| Allows derived class to receive notification of received message. More... | |
| virtual void | onTransmitMessage (const MessagePackage &message) |
| Allows derived class to receive notification of transmitted message. More... | |
A class that is used to deliver interface network messages between client and server.
In order to use a service, client needs always first to establish a session to interface.
| typedef function<bool(const MessagePackage& message)> kanzi::connect::AbstractSession::MessageReceivedFunction |
Message subscription callback.
| typedef shared_ptr<void> kanzi::connect::AbstractSession::MessageSubscriptionToken |
| typedef unordered_map<string, string> kanzi::connect::AbstractSession::ServiceAttributes |
| kanzi::connect::AbstractSession::AbstractSession | ( | const string & | interfaceId, |
| int | clientId, | ||
| int | sessionId, | ||
| MessageDispatcher * | dispatcher | ||
| ) |
Constructor.
| interfaceId | Id of the interface. |
| clientId | Id of the client. |
| sessionId | Id of the session. |
| dispatcher | Message dispatcher that can be used to deliver network messages. |
|
virtual |
Destructor.
| MessageSubscriptionToken kanzi::connect::AbstractSession::addMessageSubscription | ( | const string & | messageType, |
| MessageReceivedFunction | function | ||
| ) |
Subscribe all messages of type.
| messageType | Type of the messages to subscribe callbacks. |
| function | Callback to pass the subscribed messages. |
| void kanzi::connect::AbstractSession::changeMessageDispatcher | ( | MessageDispatcher * | dispatcher | ) |
Changes message dispatcher on the fly.
| dispatcher | the new dispatcher to take into use. |
| void kanzi::connect::AbstractSession::enableVerboseLogging | ( | bool | enable | ) |
Enables verbose logging for the functionality.
| enable | true to enable. defaults to false. |
| ClientDescriptorSharedPtr kanzi::connect::AbstractSession::getClientDescriptor | ( | ) | const |
Retrieve client descriptor.
| int kanzi::connect::AbstractSession::getClientId | ( | ) | const |
Retrieve client id of the session.
| int kanzi::connect::AbstractSession::getId | ( | ) | const |
Retrieve id of the session.
| const string& kanzi::connect::AbstractSession::getInterfaceId | ( | ) | const |
Retrieve id of the interface.
| int kanzi::connect::AbstractSession::getServerClientId | ( | ) | const |
Retrieve server client identifier of the session.
|
inline |
|
virtual |
Initializes this session.
|
protectedvirtual |
Allows derived class to receive notification of received message.
| message | Message that was received. |
Reimplemented in kanzi::connect::ClientStreamSession, and kanzi::connect::ExternalServiceSession.
|
protectedvirtual |
Allows derived class to receive notification of transmitted message.
| message | Message to send. |
| void kanzi::connect::AbstractSession::receive | ( | const MessagePackage & | message | ) |
Asks session to process received message.
| message | Message that was received. |
| void kanzi::connect::AbstractSession::removeMessageSubscription | ( | const string & | messageType, |
| MessageSubscriptionToken | token | ||
| ) |
Remove message subscription.
| messageType | Type of the messages to unsubscribe callbacks. |
| token | Subscription token. |
| void kanzi::connect::AbstractSession::setClientDescriptor | ( | ClientDescriptorSharedPtr | clientDescriptor | ) |
Saves a client descriptor of the client who created this session.
| clientDescriptor |
| void kanzi::connect::AbstractSession::setClientP2PRoutingInstructions | ( | shared_ptr< p2p::P2PClient::RoutingHandler > | routingHandler | ) |
Configure P2P routing instructions for the client.
| routingHandler | the instructions to apply. |
| void kanzi::connect::AbstractSession::setGenericInvoker | ( | GenericInvoker * | invoker | ) |
Setups generic invocation mechanism.
| invoker | generic invocation mechanism. |
| void kanzi::connect::AbstractSession::setServerClientId | ( | int | id | ) |
Sets servers identifier of the client this session belongs to.
| id | the identifier. |
| void kanzi::connect::AbstractSession::setServerP2PRouter | ( | p2p::P2PServerSharedPtr | serverRouter | ) |
Configure P2P routing for server scope.
| serverRouter | routing functionality for server. |
| void kanzi::connect::AbstractSession::terminate | ( | ) |
Terminates the session.
| bool kanzi::connect::AbstractSession::transmit | ( | const MessagePackage & | message | ) |
Sends outgoing message to network.
| message | Message to send. |
| bool kanzi::connect::AbstractSession::transmit | ( | MessagePackageSharedPtr | message, |
| uint32_t | call_handle = 0 |
||
| ) |
Sends outgoing message to network.
| message | Message to send. |
|
virtual |
Un-initializes this session.
| void kanzi::connect::AbstractSession::updateEnabledState | ( | bool | newEnabledState | ) |
Update the enabled state of this session.
| newEnabledState | The new status. |