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.

Parameters

interfaceId – Identifier of the service.

Returns

New session if service host was found.

ServiceHostSharedPtr getServiceHost(int sessionId)

Get service host for session identifier.

Parameters

sessionId – The identifier for a session.

Returns

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

AbstractSessionSharedPtr getSession(int sessionId)

Get session for identifier.

Parameters

sessionId – The identifier for a session.

Returns

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

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.

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

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

Returns

True if message was sent.

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

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