Home Manual Reference Source
import Reach from 'webcom-reach/src/Reach.js'
public class | source

Reach

Entry point for Reach SDK

Static Member Summary

Static Public Members
public static get

The browser's details

public static get

codecs: {audio: Codec/audio, video: Codec/video}: {"audio": *, "video": *}

The codec presets to use when setting Config#preferredAudioCodec or Config#preferredVideoCodec

public static get

events: {room: Events/Room, reach: Events/Reach, stream: Events/Stream}: {"room": *, "reach": *, "stream": *, "invite": *}

The supported events

public static get

media: Media: *

Media utility functions

public static get

The supported stream types

public static get

version: {sdk: string, schema: string}: {"sdk": *, "schema": *}

Get versions of SDK and DataModel.The Schema version can be used to determine compatibility with the Android & iOS SDK.

Constructor Summary

Public Constructor
public

Create Reach's data structure where the url points to (might not be the root of your namespace)

Member Summary

Public Members
public get

DataSync reference

public get

The configuration

public get

The connected User

public get

Get a list of all opened PeerConnections

Method Summary

Public Methods
public

Sign-in an anonymous user

public

createRoom(name: string, extra: object, publicRoom: boolean): Promise<Room>

Create a new room

public

Get a Room from its uid

public

Get a User from its uid

public

Get the list of invites

public

login(email: string, password: string, name: string, rememberMe: boolean): Promise<User>

Sign-in an existing user

public

Logout current user

public

on(event: string, callback: function, cancelCallback: Webcom/api.Query~cancelCallback)

Register a callback for a specific event

public

register(email: string, password: string, name: string, rememberMe: boolean): Promise<User>

Register & Sign-in as a new user

public

Resume previous session

public

Get the list of rooms

public

users(include: boolean): Promise<User[], Error>

this method is experimental. Since 'search' and 'paging' features are not yet implemented in DataSync, this call can lead to a lot data being exchanged over the WebSocket. Avoid it if your users base is pretty large.

Get the list of registered users

Static Public Members

public static get browser: Browser: * source

The browser's details

Return:

Browser

public static get codecs: {audio: Codec/audio, video: Codec/video}: {"audio": *, "video": *} source

The codec presets to use when setting Config#preferredAudioCodec or Config#preferredVideoCodec

Return:

{audio: Codec/audio, video: Codec/video}

public static get events: {room: Events/Room, reach: Events/Reach, stream: Events/Stream}: {"room": *, "reach": *, "stream": *, "invite": *} source

The supported events

Return:

{room: Events/Room, reach: Events/Reach, stream: Events/Stream}

public static get media: Media: * source

Media utility functions

Return:

Media

public static get types: StreamTypes: * source

The supported stream types

Return:

StreamTypes

public static get version: {sdk: string, schema: string}: {"sdk": *, "schema": *} source

Get versions of SDK and DataModel.The Schema version can be used to determine compatibility with the Android & iOS SDK.

Return:

{sdk: string, schema: string}

Public Constructors

public constructor(url: string | Webcom, cfg: Config) source

Create Reach's data structure where the url points to (might not be the root of your namespace)

Params:

NameTypeAttributeDescription
url string | Webcom

The url of your namespace or an existing Webcom reference.

cfg Config
  • optional

Reach configuration. You can pass constraints here

Example:

Init with the default configuration
var myReach = new Reach('https://io.datasync.orange.com/base/<my_namespace>');
Init and set constraints for SD video and logLevel to 'info'
var myReach = new Reach('https://io.datasync.orange.com/base/<my_namespace>', {
 constraints: Reach.media.constraints('SD'),
 logLevel: 'INFO'
});

Public Members

public get base: Webcom source

DataSync reference

public get config: Config source

The configuration

public get current: User source

The connected User

public get peerConnections: *: * source

Get a list of all opened PeerConnections

Return:

*

Public Methods

public anonymous(name: string): Promise<User> source

Sign-in an anonymous user

Params:

NameTypeAttributeDescription
name string

The display name of the user

Return:

Promise<User>

public createRoom(name: string, extra: object, publicRoom: boolean): Promise<Room> source

Create a new room

Params:

NameTypeAttributeDescription
name string
  • optional

The room name

extra object
  • optional

Extra informations

publicRoom boolean
  • optional
  • default: false

Indicates public room

Return:

Promise<Room>

public getRoom(uid: string): Promise<Room> source

Get a Room from its uid

Params:

NameTypeAttributeDescription
uid string

The room's UID

Return:

Promise<Room>

public getUser(uid: string): Promise<User> source

Get a User from its uid

Params:

NameTypeAttributeDescription
uid string

The user's UID

Return:

Promise<User>

public invites(): Promise<Invite[], Error> source

Get the list of invites

Return:

Promise<Invite[], Error>

public login(email: string, password: string, name: string, rememberMe: boolean): Promise<User> source

Sign-in an existing user

Params:

NameTypeAttributeDescription
email string

The email of the user

password string

The password of the user

name string
  • optional

The name of the user. Defaults to the value in base.

rememberMe boolean
  • optional
  • default: false

keep user connected ?

Return:

Promise<User>

public logout(): Promise source

Logout current user

Return:

Promise

public on(event: string, callback: function, cancelCallback: Webcom/api.Query~cancelCallback) source

Register a callback for a specific event

Params:

NameTypeAttributeDescription
event string

The event name (Events/Reach). Can be:

  • USER_ADDED
  • USER_CHANGED
  • USER_REMOVED
  • ROOM_ADDED
  • ROOM_CHANGED
  • ROOM_REMOVED
  • INVITE_ADDED
  • INVITE_CHANGED
callback function

The callback for the event, the arguments depends on the type of event:

  • USER_*: callback(User u)
  • ROOM_*: callback(Room r)
  • INVITE_*: callback(Invite i)
cancelCallback Webcom/api.Query~cancelCallback
  • optional

The error callback for the event, takes an Error as only argument

public register(email: string, password: string, name: string, rememberMe: boolean): Promise<User> source

Register & Sign-in as a new user

Params:

NameTypeAttributeDescription
email string

The email of the user

password string

The password of the user

name string
  • optional

The display name of the user (defaults to email)

rememberMe boolean
  • optional
  • default: false

keep user connected ?

Return:

Promise<User>

public resume(): Promise<User> source

Resume previous session

Return:

Promise<User>

public rooms(): Promise<Room[], Error> source

Get the list of rooms

Return:

Promise<Room[], Error>

public users(include: boolean): Promise<User[], Error> source

this method is experimental. Since 'search' and 'paging' features are not yet implemented in DataSync, this call can lead to a lot data being exchanged over the WebSocket. Avoid it if your users base is pretty large.

Get the list of registered users

Params:

NameTypeAttributeDescription
include boolean
  • optional
  • default: false

Include current user in user's list

Return:

Promise<User[], Error>