EkoClient

EkoClient

The EkoClient class serves as an SDK entry point. Should be instantiated with an Application key and be retained by the caller. A valid context instance should be used to create other SDK resources afterwards.

Constructor

new EkoClient(parameters)

Example
// Instantiate Eko SDK
const eko = new EkoClient({ apiKey: 'Your-API-Key' });
Parameters:
Name Type Description
parameters Object The container with parameters.
Properties
Name Type Description
apiKey string The Application key (API key) provided by eko.
Fires:
Throws:
  • Will throw an error in case on attempt to create more than one instance of the EkoClient.
    Type
    EkoSDKError
  • Will throw an error if parameters are wrong.
    Type
    EkoSDKInvalidParameterError

Extends

  • EventEmitter

Members

(readonly) currentUserId :String

Get current user ID
Type:
  • String

(readonly) connectionStatus :EkoConnectionStatus

Get connection status.
Type:

(readonly) currentUser :LiveObject

Get current user. The LiveObject of the UserModel
Type:

Methods

(static) create(parameters) → {EkoClient}

Create an eko SDK.
Parameters:
Name Type Description
parameters Object The container with parameters.
Properties
Name Type Description
apiKey string The Application key (API key) provided by eko.
Throws:
  • Will throw an error in case on attempt to create more than one instance of the EkoClient.
    Type
    EkoSDKError
  • Will throw an error if parameters are wrong.
    Type
    EkoSDKInvalidParameterError
Returns:
An EkoClient instance.
Type
EkoClient

registerSession(parameters)

Register session
Parameters:
Name Type Description
parameters Object The container with parameters.
Properties
Name Type Attributes Description
userId String The user ID to authenticate SDK with.
displayName String <optional>
The disply name of the user.
Throws:
Will throw an error if parameters are wrong.
Type
EkoSDKInvalidParameterError

unregisterSession()

Unregister session. Removes all user related state from memory; disconnects and disposes the EkoClient instance.

setDisplayName(displayName) → {Promise.<undefined, EkoSDKError>}

Set current user display name
Parameters:
Name Type Description
displayName String The new display name.
Throws:
Will throw an error if current user is not available (a session was not registered) or parameters are wrong.
Type
EkoSDKInvalidParameterError
Returns:
Type
Promise.<undefined, EkoSDKError>

setRoles(roles) → {Promise.<undefined, EkoSDKError>}

Set current user roles
Parameters:
Name Type Description
roles Array.<string> Set current user roles.
Throws:
Will throw an error if current user is not available (a session was not registered) or parameters are wrong.
Type
EkoSDKInvalidParameterError
Returns:
Type
Promise.<undefined, EkoSDKError>

setUserMetadata(metadata) → {Promise.<undefined, EkoSDKError>}

Set current user metadata
Parameters:
Name Type Description
metadata Object Set current user metadata.
Throws:
Will throw an error if current user is not available (a session was not registered) or parameters are wrong.
Type
EkoSDKInvalidParameterError
Returns:
Type
Promise.<undefined, EkoSDKError>

Events

connectionStatusChanged

Properties:
Name Type Attributes Description
oldValue EkoConnectionStatus <optional>
The old connection status.
newValue EkoConnectionStatus The new connection status.
Fires every time when connection status changes.
Type:
  • Object

dataError

Fires every time a connection error occurs
Type:
  • EkoSDKError