Sessions

class Sessions

The session service.

This class allows performing session related actions like establishing a new one, restoring a session that already exists, suspending it or disconnecting it when the session has to be ended. It also allows adding a listener to receive the session state (@see SessionsListener).

Properties

Link copied to clipboard
val currentState: Session.State

Current session state.

Link copied to clipboard
val id: String?

Identifier of the current user when the session is connected. If the session is still not connected, value will be null.

Link copied to clipboard

Checks if the user has enabled the Do-Not-Disturb option. By default, the value is false. The value will be null while the session is not connected.

Link copied to clipboard

Access to the reactive API of the service.

Link copied to clipboard

Session token when the session is connected. If the session is still not connected, value will be null.

Link copied to clipboard

Username of the current user when the session is connected. If the session is still not connected, value will be null.

Functions

Link copied to clipboard

Adds a listener to receive session state events.

Link copied to clipboard

Checks if there is enough information to restore the session.

Link copied to clipboard
fun connect(authentication: Authentication, context: Context)

Connects a new session.

Link copied to clipboard
fun disconnect(context: Context)

Destroys the active session established against the server. IMPORTANT: After invoking this method, the session will be no longer active and a new SippoClient instance needs to be configured.

Link copied to clipboard
fun enableDoNotDisturb(context: Context, isEnabled: Boolean, onCompletion: (SippoResourceError?) -> Unit)

Enables/Disables the Do-Not-Disturb option. When activated, disables the current Firebase token to avoid receiving push notifications from the server and blocks incoming calls received through socket.

Link copied to clipboard
fun fetchAuthProvider(onComplete: (Either<AuthProvider, SippoResourceError>) -> Unit)

Fetches the available AuthProvider.

Link copied to clipboard
fun getLocalUser(onCompletion: (Either<WacUser, SippoResourceError>) -> Unit)

Retrieves the information of the local user.

Link copied to clipboard
fun getSessionId(onCompletion: (Either<String?, SippoResourceError>) -> Unit)

Retrieves the session identifier in the signaling server. The identifier will be null if the session has not been established yet.

Link copied to clipboard

Checks if a permission is granted for the user in the current session.

Link copied to clipboard

Removes the specified listener.

Link copied to clipboard
fun restore(context: Context)

Restores the active session.

Link copied to clipboard
fun setPushToken(context: Context, token: String)

Sets a new Firebase token to receive push notifications from the server. It is recommended to call it when Firebase provides the token to the application. The SDK will register this token for the current session (if any) and for the following ones. If another token is provided, the method should be called again with the new value.

Link copied to clipboard
fun suspend()

Suspends the active session. It should be called when the application goes to background.

Link copied to clipboard
fun updateLocalUser(user: WacUser, onCompletion: (Either<WacUser, SippoResourceError>) -> Unit)

Updates de local user.