Kanzi Connect  1.1.10
Kanzi Connect C++ API
kanzi::connect::AbstractSession Class Reference

A class that is used to deliver interface network messages between client and server. More...

#include <abstract_session.hpp>

Inheritance diagram for kanzi::connect::AbstractSession:
kanzi::connect::ClientStreamSession kanzi::connect::ExternalClientSession kanzi::connect::ExternalServiceSession

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 ServiceAttributesgetServiceAttributes ()
 
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...
 

Detailed Description

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.

Member Typedef Documentation

◆ MessageReceivedFunction

Message subscription callback.

Returns
True if message was handled and framework does not need to process it further.

◆ MessageSubscriptionToken

◆ ServiceAttributes

typedef unordered_map<string, string> kanzi::connect::AbstractSession::ServiceAttributes

Constructor & Destructor Documentation

◆ AbstractSession()

kanzi::connect::AbstractSession::AbstractSession ( const string &  interfaceId,
int  clientId,
int  sessionId,
MessageDispatcher dispatcher 
)

Constructor.

Parameters
interfaceIdId of the interface.
clientIdId of the client.
sessionIdId of the session.
dispatcherMessage dispatcher that can be used to deliver network messages.

◆ ~AbstractSession()

virtual kanzi::connect::AbstractSession::~AbstractSession ( )
virtual

Destructor.

Member Function Documentation

◆ addMessageSubscription()

MessageSubscriptionToken kanzi::connect::AbstractSession::addMessageSubscription ( const string &  messageType,
MessageReceivedFunction  function 
)

Subscribe all messages of type.

Parameters
messageTypeType of the messages to subscribe callbacks.
functionCallback to pass the subscribed messages.
Returns
Subscription token which is needed to unsubscribe callbacks.

◆ changeMessageDispatcher()

void kanzi::connect::AbstractSession::changeMessageDispatcher ( MessageDispatcher dispatcher)

Changes message dispatcher on the fly.

Parameters
dispatcherthe new dispatcher to take into use.

◆ enableVerboseLogging()

void kanzi::connect::AbstractSession::enableVerboseLogging ( bool  enable)

Enables verbose logging for the functionality.

Parameters
enabletrue to enable. defaults to false.

◆ getClientDescriptor()

ClientDescriptorSharedPtr kanzi::connect::AbstractSession::getClientDescriptor ( ) const

Retrieve client descriptor.

Returns
client descriptor

◆ getClientId()

int kanzi::connect::AbstractSession::getClientId ( ) const

Retrieve client id of the session.

Returns
Network id of the client.

◆ getId()

int kanzi::connect::AbstractSession::getId ( ) const

Retrieve id of the session.

Returns
Id of the session, unique for this client.

◆ getInterfaceId()

const string& kanzi::connect::AbstractSession::getInterfaceId ( ) const

Retrieve id of the interface.

Returns
Id of the connected interface.

◆ getServerClientId()

int kanzi::connect::AbstractSession::getServerClientId ( ) const

Retrieve server client identifier of the session.

Returns
the server identifier for this client inside the server.

◆ getServiceAttributes()

const ServiceAttributes& kanzi::connect::AbstractSession::getServiceAttributes ( )
inline

◆ initialize()

virtual void kanzi::connect::AbstractSession::initialize ( )
virtual

Initializes this session.

◆ onReceiveMessage()

virtual shared_ptr<GenericRPCReplyMessage> kanzi::connect::AbstractSession::onReceiveMessage ( const MessagePackage message)
protectedvirtual

Allows derived class to receive notification of received message.

Parameters
messageMessage that was received.

Reimplemented in kanzi::connect::ClientStreamSession, and kanzi::connect::ExternalServiceSession.

◆ onTransmitMessage()

virtual void kanzi::connect::AbstractSession::onTransmitMessage ( const MessagePackage message)
protectedvirtual

Allows derived class to receive notification of transmitted message.

Parameters
messageMessage to send.

◆ receive()

void kanzi::connect::AbstractSession::receive ( const MessagePackage message)

Asks session to process received message.

Parameters
messageMessage that was received.

◆ removeMessageSubscription()

void kanzi::connect::AbstractSession::removeMessageSubscription ( const string &  messageType,
MessageSubscriptionToken  token 
)

Remove message subscription.

Parameters
messageTypeType of the messages to unsubscribe callbacks.
tokenSubscription token.

◆ setClientDescriptor()

void kanzi::connect::AbstractSession::setClientDescriptor ( ClientDescriptorSharedPtr  clientDescriptor)

Saves a client descriptor of the client who created this session.

Parameters
clientDescriptor

◆ setClientP2PRoutingInstructions()

void kanzi::connect::AbstractSession::setClientP2PRoutingInstructions ( shared_ptr< p2p::P2PClient::RoutingHandler routingHandler)

Configure P2P routing instructions for the client.

Parameters
routingHandlerthe instructions to apply.

◆ setGenericInvoker()

void kanzi::connect::AbstractSession::setGenericInvoker ( GenericInvoker invoker)

Setups generic invocation mechanism.

Parameters
invokergeneric invocation mechanism.

◆ setServerClientId()

void kanzi::connect::AbstractSession::setServerClientId ( int  id)

Sets servers identifier of the client this session belongs to.

Parameters
idthe identifier.

◆ setServerP2PRouter()

void kanzi::connect::AbstractSession::setServerP2PRouter ( p2p::P2PServerSharedPtr  serverRouter)

Configure P2P routing for server scope.

Parameters
serverRouterrouting functionality for server.

◆ terminate()

void kanzi::connect::AbstractSession::terminate ( )

Terminates the session.

◆ transmit() [1/2]

bool kanzi::connect::AbstractSession::transmit ( const MessagePackage message)

Sends outgoing message to network.

Parameters
messageMessage to send.

◆ transmit() [2/2]

bool kanzi::connect::AbstractSession::transmit ( MessagePackageSharedPtr  message,
uint32_t  call_handle = 0 
)

Sends outgoing message to network.

Parameters
messageMessage to send.

◆ uninitialize()

virtual void kanzi::connect::AbstractSession::uninitialize ( )
virtual

Un-initializes this session.

◆ updateEnabledState()

void kanzi::connect::AbstractSession::updateEnabledState ( bool  newEnabledState)

Update the enabled state of this session.

Parameters
newEnabledStateThe new status.

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