ConnectedClientProxy

class kanzi::connect::ConnectedClientProxy : public ConnectedClient

Public Functions

ConnectedClientProxy(ServiceManagerSharedPtr serviceManager, MessageDispatcherSharedPtr dispatcher, int clientId)

Constructor.

Parameters
  • serviceManager: The interface to be used when finding service hosts and sending messages.

  • dispatcher: The message dispatcher to be used with responses.

  • clientId: The client identifier used when communicating with services, needs to be unique.

~ConnectedClientProxy()

Destructor.

optional<int> acquireSession(const string &interfaceId)

Acquire new client session to be used with this client.

Return

New session if service host was found.

Parameters
  • interfaceId: Identifier of the service.

ServiceHostSharedPtr getServiceHost(int sessionId)

Get service host for session identifier.

Return

On success, return a pointer to a service host, nullptr otherwise.

Parameters
  • sessionId: The identifier for a session.

AbstractSessionSharedPtr getSession(int sessionId)

Get session for identifier.

Return

On success, return a pointer to a session, nullptr otherwise.

Parameters
  • sessionId: The identifier for a session.

void releaseSession(int sessionId)

Sends a stop message through the message handler and release the allocated session.

Parameters
  • sessionId: The identifier of a session to be released. If session id is not found, the method does nothing.

bool send(MessagePackage &message, int sessionId)

Send a message through client.

Modify message package with session information.

Return

True if message was sent.

Parameters
  • message: The message package to be modified and sent.

  • sessionId: The identifier for the session to be used when sending.

void setConnectionManager(ConnectionManagerSharedPtr connectionManager)

If the given client identifier was allocated from client id manager, set the connection manager so that client can release the handle upon destruction.

Parameters
  • connectionManager: The connection manager instance that was used when allocating the client identifier.

Public Static Functions

ConnectedClientProxySharedPtr create(const string &name, ConnectDomain *connectDomain, MessageDispatcherSharedPtr dispatcher, const string &clientIdMgrType)