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. | |
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. | |
MessageSubscriptionToken | addMessageSubscription (const string &messageType, MessageReceivedFunction function) |
Subscribe all messages of type. | |
MessageSubscriptionToken | addMessageTypeSubscription (int messageType, MessageReceivedFunction function) |
Subscribe all messages of Message Package type. | |
MessageSubscriptionToken | addRegexMessageSubscription (const string ®ex, MessageReceivedFunction function) |
Subscribe all messages that match a regular expression. | |
void | changeMessageDispatcher (MessageDispatcher *dispatcher) |
Changes message dispatcher on the fly. | |
void | enableVerboseLogging (bool enable) |
Enables verbose logging for the functionality. | |
ClientDescriptorSharedPtr | getClientDescriptor () const |
Retrieve client descriptor. | |
int | getClientId () const |
Retrieve client id of the session. | |
int | getId () const |
Retrieve id of the session. | |
const string & | getInterfaceId () const |
Retrieve id of the interface. | |
int | getServerClientId () const |
Retrieve server client identifier of the session. | |
const ServiceAttributes & | getServiceAttributes () |
virtual void | initialize () |
Initializes this session. | |
void | receive (const MessagePackage &message) |
Asks session to process received message. | |
void | removeMessageSubscription (const string &messageType, MessageSubscriptionToken token) |
Remove message subscription. | |
void | removeMessageTypeSubscription (int messageType, MessageSubscriptionToken token) |
Remove message subscription. | |
void | removeRegexMessageSubscription (const string ®ex, MessageSubscriptionToken token) |
Remove regular expression message subscription. | |
void | setClientDescriptor (ClientDescriptorSharedPtr clientDescriptor) |
Saves a client descriptor of the client who created this session. | |
void | setClientP2PRoutingInstructions (shared_ptr< p2p::P2PClient::RoutingHandler > routingHandler) |
Configure P2P routing instructions for the client. | |
void | setGenericInvoker (GenericInvoker *invoker) |
Setups generic invocation mechanism. | |
void | setServerClientId (int id) |
Sets servers identifier of the client this session belongs to. | |
void | setServerP2PRouter (p2p::P2PServerSharedPtr serverRouter) |
Configure P2P routing for server scope. | |
void | terminate () |
Terminates the session. | |
bool | transmit (const MessagePackage &message) |
Sends outgoing message to network. | |
bool | transmit (MessagePackageSharedPtr message, uint32_t call_handle=0) |
Sends outgoing message to network. | |
virtual void | uninitialize () |
Un-initializes this session. | |
void | updateEnabledState (bool newEnabledState) |
Update the enabled state of this session. | |
virtual | ~AbstractSession () |
Destructor. | |
Protected Member Functions | |
virtual shared_ptr< GenericRPCReplyMessage > | onReceiveMessage (const MessagePackage &message) |
Allows derived class to receive notification of received message. | |
virtual void | onTransmitMessage (const MessagePackage &message) |
Allows derived class to receive notification of transmitted message. | |
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. |
MessageSubscriptionToken kanzi::connect::AbstractSession::addMessageTypeSubscription | ( | int | messageType, |
MessageReceivedFunction | function ) |
Subscribe all messages of Message Package type.
messageType | Type of the messages to subscribe callbacks. |
function | Callback to pass the subscribed messages. |
MessageSubscriptionToken kanzi::connect::AbstractSession::addRegexMessageSubscription | ( | const string & | regex, |
MessageReceivedFunction | function ) |
Subscribe all messages that match a regular expression.
regex | Regular expression for matching messages. |
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::ExternalServiceSession, and kanzi::connect::ClientStreamSession.
|
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::removeMessageTypeSubscription | ( | int | messageType, |
MessageSubscriptionToken | token ) |
Remove message subscription.
messageType | Type of the messages to unsubscribe callbacks. |
token | Subscription token. |
void kanzi::connect::AbstractSession::removeRegexMessageSubscription | ( | const string & | regex, |
MessageSubscriptionToken | token ) |
Remove regular expression message subscription.
regex | Regular expression to unsubscribe. |
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. |