Class: WRTCClient

WRTCClient(config)

new WRTCClient(config)

Create a WebRTC client
Parameters:
Name Type Description
config object The configuration object
Properties
Name Type Description
serverUrl string The server URL
iceServers Array The ICE Server descriptor array
maxAvgBitrate number The maximum average stream bitrate

Members

onaudiostreamlevelchanged :WRTCClient~onAudioStreamLevelChanged

Called when changed audio level from a audio stream
Type:

oncastroomsoccupancies :WRTCClient~onCastRoomsOccupancies

Called when received room occupancies
Type:

onchatmessage :WRTCClient~onChatMessage

Called when received a chat message
Type:

onconnect :WRTCClient~onEvent

Called when connected to server
Type:

ondisconnect :WRTCClient~onEvent

Called when disconnected from server
Type:

oninsideroompeermicenabledstatechanged :WRTCClient~onInsideRoomPeerMicEnabledStateChanged

Called when a remote peer in current room changed the mic enabled state
Type:

oninsideroompeermutestatechanged :WRTCClient~onInsideRoomPeerMuteStateChanged

Called when a remote peer in current room changed the mic mute state
Type:

oninsideroompeersspotchanged :WRTCClient~onInsideRoomPeersSpotChanged

Called when a remote peer changed the spot in current room
Type:

onmixedaudiostreamavailable :WRTCClient~onMixedAudioStreamAvailable

Called when the mixed audio stream is available
Type:

onmixedaudiostreamremoved

Called when the mixed audio stream is removed

onremotestreamavailable :WRTCClient~onRemoteStreamAvailable

Called when a remote stream is available
Type:

onremotestreamremoved :WRTCClient~onRemoteStreamRemoved

Called when a remote stream is removed
Type:

onrequestinsideroompeersinfosresponse :WRTCClient~onRequestInsideRoomPeersInfosResponse

Called when received peer's infos
Type:

Methods

connect(name) → {void}

Connect to the server
Parameters:
Name Type Description
name string The peer name (temporary parameter)
Returns:
Type
void

createFloor(name, universeIndex, xSize, ySize, additionalProperties, onSuccess, onFailed) → {void}

Creates a new floor
Parameters:
Name Type Description
name string The name of the new floor
universeIndex number The index of the universe
xSize number The size of the floor on x axis
ySize number The size of the floor on y axis
additionalProperties object Additional properties (future use)
onSuccess WRTCClient~onSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

disconnect() → {void}

Disconnect from server
Returns:
Type
void

getMediaDevicesMonitor() → {object}

Gets the MediaDevicesMonitor
Returns:
Type
object

joinFloor(floorName, universeIndex, onJoinFloorSuccess, onFailed) → {void}

Join to a floor
Parameters:
Name Type Description
floorName string The floor name
universeIndex number The universe index
onJoinFloorSuccess WRTCClient~onJoinFloorSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

joinRoom(name, spotInd, onSuccess, onFailed) → {void}

Join to a room
Parameters:
Name Type Description
name string The room name
spotInd number The spot index
onSuccess WRTCClient~onSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

leaveFloor() → {void}

Leave the floor
Returns:
Type
void

leaveRoom() → {void}

Leave the room
Returns:
Type
void

loginPeer(peerName, jwtopt, onSuccess, onFailed) → {void}

Login peer in server
Parameters:
Name Type Attributes Description
peerName string
jwt string <optional>
onSuccess WRTCClient~onSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

removeFloor(name, universeIndex, onSuccess, onFailed) → {void}

Removes a floor
Parameters:
Name Type Description
name string The name the floor
universeIndex number The index of the universe
onSuccess WRTCClient~onSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

requestAllFloorsInfos(universeIndex, onSuccess, onFailed) → {void}

Requests floors' infos of all floor in a universe
Parameters:
Name Type Description
universeIndex number The index of the universe
onSuccess WRTCClient~onRequestAllFloorsInfosSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

requestFloorOccupancy(floorName, universeIndex, onSuccess, onFailed) → {void}

Requests the occupancy of a floor
Parameters:
Name Type Description
floorName string The floor name
universeIndex number The universe index
onSuccess WRTCClient~onRequestFloorOccupancySuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

requestFloorsOccupancies(universeIndex, onSuccess, onFailed) → {void}

Requests the occuppancies of all floors
Parameters:
Name Type Description
universeIndex number The universe index
onSuccess WRTCClient~onRequestFloorsOccupanciesSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

requestInsideRoomPeersInfos() → {void}

Requests peer's infos of the current room (See onrequestinsideroompeersinfosresponse)
Returns:
Type
void

requestPeersState(peerId, onSuccess, onFailed) → {void}

Requests a peer's state
Parameters:
Name Type Description
peerId number The peer's id
onSuccess WRTCClient~onRequestPeersStateSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

requestRoomState(name, floorNname, universeIndex, onSuccess, onFailed) → {void}

Requests a room current state
Parameters:
Name Type Description
name string The room name
floorNname string The floor name
universeIndex number The index of the universe
onSuccess WRTCClient~onRequestRoomStateSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

requestRoomsOccupancies(floorName, universeIndex, onSuccess, onFailed) → {void}

Requests rooms' occupancies in a floor
Parameters:
Name Type Description
floorName string The floor name
universeIndex number The index of the universe
onSuccess WRTCClient~onRequestRoomsOccupanciesSuccess
onFailed WRTCClient~onFailed
Returns:
Type
void

sendChatMessage(messageObject, dstPeerId) → {void}

Sends a chat message
Parameters:
Name Type Description
messageObject object The message object
dstPeerId number The remote peer's id (or INVALID_PEER_ID to broadcast)
Returns:
Type
void

setAudioInputDevice(deviceId) → {Promise}

Sets the audio input device
Parameters:
Name Type Description
deviceId string The device id
Returns:
Type
Promise

setLocalInputDeviceGain(gain) → {void}

Sets the gain of the local mic
Parameters:
Name Type Description
gain number The gain (between 0 and 1)
Returns:
Type
void

setLocalInputDeviceMuteState(mute) → {void}

Sets the mute state of the local mic
Parameters:
Name Type Description
mute boolean The mute state
Returns:
Type
void

setLogLevel(level) → {void}

Sets the log level
Parameters:
Name Type Description
level string The name of the level: 'info', 'warn', 'debug', 'error'
Returns:
Type
void

setReverbImpulseResponse(url) → {Promise}

Sets the impulse response audio file used to create reverb effect
Parameters:
Name Type Description
url string The url of the audio file
Returns:
Type
Promise

setVirtualRoomFrameSize(cols, rows) → {void}

Sets the size of the room in terms of spot
Parameters:
Name Type Description
cols number The number of cols
rows number The number of rows
Returns:
Type
void

tryChangeInsideRoomSpot(col, row) → {void}

Tries to change the spot in current room
Parameters:
Name Type Description
col number The col of the spot
row number The row of the spot
Returns:
Type
void

trySetAudioOutputDevice(deviceId) → {Promise}

Tries to set the audio output device
Parameters:
Name Type Description
deviceId string The device id
Returns:
Type
Promise

Type Definitions

Error

Type:
  • Object
Properties:
Name Type Description
msg string The error message
code number The error code

PeersInfo

Type:
  • Object
Properties:
Name Type Description
peerId number Peer's id
peerName string Peer's name
spotCoordJ number Column of the spot
spotCoordX number Row of the spot
muted bool Peer's mic mute state
micEnabled bool Peer's mic has been enabled

RoomOccupancy

Type:
  • Object
Properties:
Name Type Description
name string Room name
occup number Amount of peers in the room

onAudioStreamLevelChanged(newLevel, peerId) → {void}

Parameters:
Name Type Description
newLevel number The new audio level
peerId number The peer's id
Returns:
Type
void

onCastRoomsOccupancies(occupancies) → {void}

Parameters:
Name Type Description
occupancies Array.<WRTCClient~RoomOccupancy> A array of room occupancies
Returns:
Type
void

onChatMessage(messageObject, peerId) → {void}

Parameters:
Name Type Description
messageObject object The message object
peerId number The peer's id
Returns:
Type
void

onEvent() → {void}

Returns:
Type
void

onFailed(err) → {void}

Parameters:
Name Type Description
err WRTCClient~Error The error descriptor
Returns:
Type
void

onInsideRoomPeerMicEnabledStateChanged(newState, peerId) → {void}

Parameters:
Name Type Description
newState number The new mic enabled state
peerId number The remote peer's id
Returns:
Type
void

onInsideRoomPeerMuteStateChanged(newState, peerId) → {void}

Parameters:
Name Type Description
newState number The new mute state
peerId number The remote peer's id
Returns:
Type
void

onInsideRoomPeersSpotChanged(col, row, peerId, peerName) → {void}

Parameters:
Name Type Description
col number The spot col
row number The spot row
peerId number The peer's id
peerName string The peer's name
Returns:
Type
void

onJoinFloorSuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
size number The floor size
Properties
Name Type Description
x number The number of rooms in x-axis
y number The number of rooms in y-axis
position number The position in the universe
Properties
Name Type Description
x number The coord x of the floor
y number The coord y of the floor
z number The coord z of the floor
name string The floor name
universeIndex number The universe index
Returns:
Type
void

onMixedAudioStreamAvailable(stream) → {void}

Parameters:
Name Type Description
stream object The audio stream
Returns:
Type
void

onRemoteStreamAvailable(stream, edgeId) → {void}

Parameters:
Name Type Description
stream object The audio stream
edgeId number The edge id
Returns:
Type
void

onRemoteStreamRemoved(edgeId) → {void}

Parameters:
Name Type Description
edgeId number The edge id
Returns:
Type
void

onRequestAllFloorsInfosSuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
floors Array The floor info array
universeIndex number The universe index
Returns:
Type
void

onRequestFloorOccupancySuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
occupancy number The floor occupancy
name string The floor name
universeIndex number The universe index
Returns:
Type
void

onRequestFloorsOccupanciesSuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
floors Array The floors occupancies
universeIndex number The universe index
Returns:
Type
void

onRequestInsideRoomPeersInfosResponse(peersInfo) → {void}

Parameters:
Name Type Description
peersInfo Array.<WRTCClient~PeersInfo> A array of peer's infos
Returns:
Type
void

onRequestPeersStateSuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
state object The peer's state
Returns:
Type
void

onRequestRoomStateSuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
state object The room state
floorName string The floor name
universeIndex number The universe index
Returns:
Type
void

onRequestRoomsOccupanciesSuccess(obj) → {void}

Parameters:
Name Type Description
obj object
Properties
Name Type Description
rooms Array The room occupancies
floorName string The floor name
universeIndex number The universe index
Returns:
Type
void

onSuccess() → {void}

Returns:
Type
void