Kanzi Connect Client

Use a Kanzi Connect Client to connect an application to a Kanzi Connect Server. It allows you to set up the network connectivity and provides the access to the services running on the Kanzi Connect Server. This image shows the architecture and an overview of class dependencies of a Kanzi Connect Client.

../_images/kanzi_connect_client.png

Start-up

The start-up procedure of a Kanzi Connect Client can be split into these phases:

  1. The application creates an instance of the client and registers the client-side network interfaces into the system. The services with generic introspection interface do not need additional registration at this point. If there is generated or native C++ code, the extensions need to be registered up front.

  2. After the client is aware of the required interfaces, the application can connect to the server.

    This is done by retrieving the connection object and asking it to connect(). It is also possible to subscribe to changes in connection state and receive connected and disconnected notifications. Kanzi Connect supports the TCP/IP as a transport layer.

Runtime operation

After the connection is established, the client can use the registered network interfaces to access the connected services. There is a client-side class available per connected service, which allows client to communicate remotely with the service just by calling methods and receiving callbacks. All the networking code which sends messages between the client and server is hidden and the client does not need to be aware of it.

The client requires a periodical call to work(), which allows it to process network events. In applications that are running an event-based main loop (preserving CPU), it is possible to ask the client to wait() for network events to occur, which makes the client also preserve CPU time. The wait call is blocking, but you can use an optional timeout parameter to break it out and return. On non-event driven applications, it is usually enough just to put a call to work() in to update the loop of the application. The networking is fully asynchronous and threaded, and automatically preserves CPU time when possible.

When work() is called, the Kanzi Connect Client processes all the incoming and outgoing network events and passes messages from the connected services to their client-side counterparts (and the other way around). See Connection Service.

Shutdown

When shutting down, disconnect() automatically terminates all ongoing network sessions and tears down the networking. This call blocks until all the registered interfaces are shut down and the networking code is no longer running.

Kanzi applications

Kanzi Connect provides an adaptation library that enables you to integrate Kanzi Connect into Kanzi applications. See Kanzi Connect adaptation.