services::session

Module: Session Service

The session class.

Attention: The session_service interface contains methods that return async_result. Each function that returns async_result is asynchronous and executes operations on the SDK event loop. The caller can block the calling thread until the operation completes and can use the wait helper. The caller can also chain consecutive operations which depend on the completion of this method using async_result::then calls. When you create an async_result chain, terminate it using async_result::on_error.

#include <session.h>

Public Classes

Name
structparticipant_info
The class that represents the participant who tries to open a session.

Public Types

Name
enumstate { RECONNECTING, DISCONNECTED, CONNECTING, CONNECTED}
The current state of a session.

Public Functions

Name
virtual async_result< void >open(participant_info && identification) =0
Opens a new session for the specified participant.
virtual async_result< void >close() =0
Closes the current session.
class dolbyio::comms::services::session;

Public Types Documentation

enum state

EnumeratorDescription
RECONNECTINGThe session is reconnecting.
DISCONNECTEDThe session is disconnected, this is the initial state.
CONNECTINGThe session is connecting.
CONNECTEDThe session is connected.

The current state of a session.

Public Functions Documentation

function open

virtual async_result< void > open(
    participant_info && identification
) =0

Opens a new session for the specified participant.

Parameters:

  • identification Information about the participant who tries to open a session.

Return: The result object producing the operation status asynchronously.

// Wait for a new session to open
wait(sdk->session().open(identification));

// When the session is opened, use the `then` call:
sdk->session().open(identification)
  .then([]() {
    // session is now opened
  })
  .on_error([](auto&& e) {
    // handle exception
  });

function close

virtual async_result< void > close() =0

Closes the current session.

Return: The result object producing the operation status asynchronously.

// Wait for the session to close
wait(sdk->session().close());

// When the session is closed, use the `then` call:
sdk->session().close()
  .then([]() {
    // session is now closed
  })
  .on_error([](auto&& e) {
    // handle exception
  });


Did this page help you?