sippo-sdk / com.quobis.sippo.sipposdk.session / Sessions

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

currentState

val currentState: State

Current session state.

isDoNotDisturbEnabled

val isDoNotDisturbEnabled: Boolean

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.

rx

val rx: SessionsRx

Access to the reactive API of the service.

username

val username: String?

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

Functions

addListener

fun addListener(listener: SessionsListener): Unit

Adds a listener to receive session state events.

canRestoreSession

fun canRestoreSession(context: Context): Boolean

Checks if there is enough information to restore the session.

connect

fun connect(authentication: Authentication, context: Context): Unit

Connects a new session.

disconnect

fun disconnect(context: Context): Unit

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.

enableDoNotDisturb

fun enableDoNotDisturb(context: Context, isEnabled: Boolean, onCompletion: (SippoResourceError?) -> Unit): 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.

fetchAuthProvider

fun fetchAuthProvider(onComplete: (Either<AuthProvider, SippoResourceError>) -> Unit): Unit

Fetches the available AuthProvider.

fetchProviders

fun fetchProviders(onComplete: (Either<List<Provider>, SippoResourceError>) -> Unit): Unit

Fetches the available Provider.

getLocalUser

fun getLocalUser(onCompletion: (Either<User, SippoResourceError>) -> Unit): Unit

Retrieves the information of the local user.

getSessionId

fun getSessionId(onCompletion: (Either<String?, SippoResourceError>) -> Unit): Unit

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

isPermissionGranted

fun isPermissionGranted(permission: Permission): Boolean

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

removeListener

fun removeListener(listener: SessionsListener): Unit

Removes the specified listener.

restore

fun restore(context: Context): Unit

Restores the active session.

setPushToken

fun setPushToken(context: Context, token: String): Unit

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.

suspend

fun suspend(): Unit

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

updateLocalUser

fun updateLocalUser(user: User, onCompletion: (Either<User, SippoResourceError>) -> Unit): Unit

Updates de local user.