SessionManager

This module imports the Session Manager, a special Session Client for UDP-based routers who need to create a session.

DropConnectionTimeoutCallback()
class SessionManager(router: ~kortex_api.RouterClient.RouterClient, connectionTimeoutCallback=<function DropConnectionTimeoutCallback>)

The SessionManager is a special SessionClient that is used with UDP (low-level) communication to create and close sessions.

Kortex Routers created with a UDPTransport have to create a session with the SessionManager to properly interact with a Kortex device.

Kortex Routers created with a MqttTransport have to create a session using the auto-generated SessionClient.

Usage :

# Create the UDPTransport, RouterClient and connect the transport...

sessionManager = SessionManager(router)

# Fill a CreateSessionInfo with the proper authentification information...

sessionManager.CreateSession(createSessionInfo)

# Run your app and before deactivating the RouterClient, close the session

sessionManager.CloseSession()

Constructor for SessionManager.

Parameters
  • router (RouterClient) – RouterClient that this SessionManager will use to communicate.

  • connectionTimeoutCallback (function, optional) – Custom callback when the connection is dropped. Defaults to DropConnectionTimeoutCallback.

Raises

RuntimeError – If the RouterClient was created with an MqttTransport, the exception is raised.

CloseSession(options: ~kortex_api.RouterClient.RouterClientSendOptions = <kortex_api.RouterClient.RouterClientSendOptions object>)

Closes the session.

Parameters

options (RouterClientSendOptions, optional) – Router sending options. Defaults to RouterClientSendOptions().

Raises
  • TimeoutError – The call has timed out.

  • Exception – Any other error has happened with the call.

CreateSession(createSessionInfo: ~Session_pb2.CreateSessionInfo, options: ~kortex_api.RouterClient.RouterClientSendOptions = <kortex_api.RouterClient.RouterClientSendOptions object>)

Attempts to create a session with the supplied CreateSessionInfo.

Parameters
  • createSessionInfo (Session_pb2.CreateSessionInfo) – Authentification information for session creation.

  • options (RouterClientSendOptions, optional) – Router sending options. Defaults to RouterClientSendOptions().

Raises

TimeoutError – The call has timed out and the session was not created.