ConnectionManager

class kanzi::connect::ConnectionManager : public ConnectionServiceConcept, private NetworkListener::Observer, public ConnectionManagerMessageHookInterface

A service class to manage clients on server side. Implements Connection Interface on server.

Public Types

typedef map<int, ConnectedClientSharedPtr> ClientContainer

Container for connected clients.

Public Functions

ConnectionManager(ConnectDomain *connectDomain, IncomingMessageInterface *messageRouterInterface, DiagnosticsManagerSharedPtr diagManager, ConnectionAdapterObjectFactorySharedPtr objectFactory = ConnectionAdapterObjectFactorySharedPtr())

Constructor.

Parameters
  • connectDomain: The connect domain.

  • messageRouterInterface: Interface to object that will handle incoming messages.

  • diagManager: The diagnostics manager, used to deliver diagnostics related data.

  • objectFactory: Factory interface to create connection adapters.

~ConnectionManager () KZ_OVERRIDE

Destructor.

void addMessageHook(ConnectionManagerMessageHookInterface *messageInterface)

Installs new message hook processor.

Parameters
  • messageInterface: the message interface

void addObserver(Observer *observer)

Adds observer to listen for notifications on this service.

Parameters
  • observer: Observer to add.

ClientContainer::const_iterator beginClients() const

Return iterator to container for all connected clients (begin).

Return

Iterator that points the beginning of the container.

ClientContainer::const_iterator endClients() const

Return iterator to container for all connected clients (end).

Return

Iterator that points the end of the container.

ClientIdManager &getClientIdManager()

Retrieve the client id manager class.

Return

reference to ClientIdManager instance.

ConnectionAdapter *getConnectionAdapter(const int clientId) const

Find the connection adapter that handles the connection for the given client.

Return

Pointer to the connection adapter, null pointer if not found

Parameters
  • clientId: Identifies the client

ConnectionAdapterObjectFactorySharedPtr getConnectionAdapterObjectFactory()

Retrieve the Connection adapter factory.

NetworkListenerSharedPtr getNetworkListener(const int clientId) const

Find the network listener that handlers the particular client.

Return

shared pointer to network listener object

Parameters
  • clientId: the client identifier

void initialize (InterfaceDomainBase *domain, ContentClientSharedPtr contentClient, WorkQueueInterface *workQueue) KZ_OVERRIDE

See AbstractService::initialize.

AbstractSessionSharedPtr onAcquireSession(int clientId, int sessionId, MessageDispatcher *dispatcher, const string &instanceName) override

See AbstractService::onAcquireSession.

void removeMessageHook(ConnectionManagerMessageHookInterface *messageInterface)

Removes existing message hook processor.

Parameters
  • messageInterface: the message interface

void removeObserver(Observer *observer)

Remove observer to stop listening for notifications on this service.

Parameters
  • observer: Observer to remove.

void setHttpServer(shared_ptr<CivetServer> httpServer)

Set HTTP server to handle HTTP requests.

Parameters
  • httpServer: HTTP server to handle HTTP requests.

void uninitialize () KZ_OVERRIDE

See AbstractService::uninitialize.

class Observer

Observer for client connections.

Subclassed by ServiceManager

Public Functions

void onClientConnected(ConnectedClient *client) = 0

Notification about newly connected client.

Parameters
  • client: The client that connected.

void onClientDisconnected(ConnectedClient *client) = 0

Notification about disconnected client.

Parameters
  • client: The client that disconnected.

void onClientIdentified(ConnectedClient *client) = 0

Notification about client being identified (name assigned).

Parameters
  • client: The client that is being identified.