The Session Class

Python SDK, Javascript SDK

Communicating through a message bus introduce additional complexity since the response is asynchronous and not linked with a specific request (like instead could be a REST API call). To help developers in matching a response with a previously sent request, the Session class keeps track of session information (e.g. whatever attribute you need to save) when communicating with other modules. This leverages a a random request_id which is automatically generated by the SDK when creating a new Message object.

The following functions are provided:

  • register(message, session): associate the request_id of a message with a session content
  • restore(message): return session's content previously saved of a an incoming message (be leveraging the associated request_id)
  • is_registered(message): return true if this is a registered session, false otherwise