InterfaceClient

template<class ObserverClass, class SessionClass>
class kanzi::connect::InterfaceClient : public AbstractInterfaceClient

Templated abstract base class for network interfaces.

Enforces type safety in interface and implements support for observers.

Public Types

typedef map<AbstractSessionSharedPtr, ObserverClass*> ObserverContainer

Type definition for observer container.

Public Functions

inline InterfaceClient(const string &identifier, RPCCallStore &callstore)
inline AbstractSessionSharedPtr acquireSession(MessageDispatcher *dispatcher)

Acquire session in to this interface.

Parameters

dispatcher – Message dispatcher that is used to deliver network messages.

Returns

New session instance for this interface type.

inline void addObserver(AbstractSessionSharedPtr session, ObserverClass *observer)

Add observer in to this interface for given session.

Parameters
  • session – Session to observe.

  • observer – Observer to receive notifications.

inline RPCCallStore &getCallStore()

Retrieve RPC call store that is used to manage pending RPC calls.

Returns

reference to RPC callstore implementation.

inline virtual string getIdentifier() const

Returns the type id of the interface.

This is used to identify the service in the network.

Returns

Type of the interface, as a string.

inline ObserverClass *getObserver(AbstractSessionSharedPtr session)

Retrieve observer for given session.

Parameters

session – Session being observed.

Returns

Observer that is connected to session, or null if there is no such observer.

inline virtual AbstractSessionSharedPtr onAcquireSession(int sessionId, MessageDispatcher *dispatcher)

Function that allows derived classes to create their type-specific session instance.

Parameters
  • sessionId – Session Id of the connected client, needs to be unique for this client.

  • dispatcher – Message dispatcher that is used to deliver network messages.

Returns

New session instance for this type of interface.

inline virtual void receive(const MessagePackage &message)

Pass a message package to this interface, resolves proper session and makes it receive the package.

Parameters

message – Message that was sent.

inline void releaseSession(AbstractSessionSharedPtr session)

Release session that is connected to this interface.

Parameters

session – Session to release.

inline void removeObserver(AbstractSessionSharedPtr session)

Remove observer from a given session.

Parameters

session – Session to remove observer from.