A client can choose to establish a session with the Volt. For clients that are simply consuming services, this isn’t always necessary. However if a client wishes to register a service with Volt for consumption by other clients, a session is required to ensure that the Volt can reliably determine when services are online and reachable.

A session can also be useful in consumer scenarios, because it makes things like reconnection and retries easier to manage. For example, if a client wishes to set up a reliable subscription to a Volt wire, the ‘connected’ event of a session can be used to signal the start of the subscription. If the session drops for whatever reason, a ‘disconnected’ event will be sent and the client library will automatically attempt periodic reconnection. Once the session is re-established, the ‘connect’ event is fired again and the client can restart the subscription.

Service registration

Clients wishing to register a service(s) with the Volt must first establish a session. The Volt uses the session to control the lifetime of the services. If the session is dropped or explicitly closed, the Volt will move all the services registered by that client offline.

Both client libraries provide interfaces that make session creation and management relatively straight forward. See the How to establish a session section for more information.

Remote invocation

As well as service registration management, sessions are used internally by the Volt to support the Relay concept. When a Volt establishes a Relay connection to another Volt, this is done using a session. See the InvokeRequest and InvokeResponse message types for more details.

This concept could be extended to enable any client to support remote invocation of arbitrary functions, i.e. it is not restricted to Volt endpoints. For example, a web client could establish a session using the Javascript Web API, and upon receipt of a ConnectResponse message with an InvokeRequest payload respond with an appropriate InvokeResponse.