Class: Room
The Class Room offers an easy way to interact with the Odin Audio Server and ands useful functionality. For more information please visit our docs at https://4players.io.
Extends
Constructors
new Room()
new Room():
Room
Returns
Overrides
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:134
Properties
defaultGateway
readonly
defaultGateway:"https://gateway.odin.4players.io"
="https://gateway.odin.4players.io"
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:34
inputActivityInterval
inputActivityInterval:
number
Interval how often the AudioActivity of Inputs is dispatched. The lower the value, the more accurate the indicator is at the cost of performance.
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:43
onAudioActivity()?
optional
onAudioActivity: (payload
) =>void
OnAudioActivity gets called, whenever a AudioInput or AudioOutput is producing audio. Only emits, as long as voice activity detection is active.
Parameters
• payload: AudioActivityPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:83
onAudioInputStarted()?
optional
onAudioInputStarted: (payload
) =>void
OnAudioInputStarted gets called, whenever a new AudioInput was started.
Parameters
• payload: AudioInputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:105
onAudioInputStopped()?
optional
onAudioInputStopped: (payload
) =>void
OnAudioInputStopped gets called, whenever a AudioInput was stopped.
Parameters
• payload: AudioInputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:109
onAudioOutputStarted()?
optional
onAudioOutputStarted: (payload
) =>void
OnAudioOutputStarted gets called, whenever a new AudioOutput was started.
Parameters
• payload: AudioOutputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:113
onAudioOutputStopped()?
optional
onAudioOutputStopped: (payload
) =>void
OnAudioOutputStopped gets called, whenever a AudioOutput was stopped.
Parameters
• payload: AudioOutputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:117
onAudioPowerLevel()?
optional
onAudioPowerLevel: (payload
) =>void
OnAudioPowerLevel gets called based on the rmsDBFSInterval of the room and represents the latest rmsDBFS value.
Parameters
• payload: AudioActivityPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:87
onAudioStats()?
optional
onAudioStats: (payload
) =>void
Parameters
• payload: AudioStatsPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:92
onConnectionStats()?
optional
onConnectionStats: (payload
) =>void
Parameters
• payload: ConnectionStatsPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:93
onDataChanged()?
optional
onDataChanged: (payload
) =>void
OnRoomDataChanged gets called, whenever the data of the room was changed. This can only be done via admin tokens.
Parameters
• payload: RoomDataChangedPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:66
onJoined()?
optional
onJoined: (payload
) =>void
OnJoined is called, when this room was joined. Also gets called after a reconnect was successfully performed.
Parameters
• payload: PeerJoinedPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:52
onLeft()?
optional
onLeft: (payload
) =>void
OnLeft is called, when the room was disconnected by the server.
Parameters
• payload: LeftPayload
Returns
void
TODO
Check if it makes sense to call this method also by user disconnects.
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:57
onMediaStarted()?
optional
onMediaStarted: (payload
) =>void
OnMediaStarted gets called, whenever a new AudioInput or AudioOutput was started.
Parameters
• payload: MediaPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:97
onMediaStopped()?
optional
onMediaStopped: (payload
) =>void
OnMediaStopped gets called, whenever a AudioInput or AudioOutput was stopped.
Parameters
• payload: MediaPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:101
onMessageReceived()?
optional
onMessageReceived: (payload
) =>void
OnMessageReceived gets called, whenever a message in the room was received.
Parameters
• payload: MessageReceivedPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:91
onPeerJoined()?
optional
onPeerJoined: (payload
) =>void
OnPeerJoined gets called, whenever a new peer joined the room.
Parameters
• payload: PeerJoinedPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:70
onPeerLeft()?
optional
onPeerLeft: (payload
) =>void
OnPeerLeft gets called, whenever a peer leaves the room.
Parameters
• payload: PeerLeftPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:74
onStatusChanged()?
optional
onStatusChanged: (payload
) =>void
OnRoomStatusChanged gets called, whenever the status of the room changed.
Parameters
• payload: RoomStatusChangedPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:61
onUserDataChanged()?
optional
onUserDataChanged: (payload
) =>void
OnUserDataChanged gets called, whenever a peer changed its data.
Parameters
• payload: UserDataChangedPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:78
onVideoInputStarted()?
optional
onVideoInputStarted: (payload
) =>void
OnVideoInputStarted gets called, whenever a new VideoInput was started.
Parameters
• payload: VideoInputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:129
onVideoInputStopped()?
optional
onVideoInputStopped: (payload
) =>void
OnVideoInputStopped gets called, whenever a VideoInput was stopped.
Parameters
• payload: VideoInputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:133
onVideoOutputStarted()?
optional
onVideoOutputStarted: (payload
) =>void
OnVideoOutputStarted gets called, whenever a new VideoOutput was started.
Parameters
• payload: VideoOutputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:121
onVideoOutputStopped()?
optional
onVideoOutputStopped: (payload
) =>void
OnVideoOutputStopped gets called, whenever a VideoOutput was stopped.
Parameters
• payload: VideoOutputPayload
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:125
outputActivityInterval
outputActivityInterval:
number
Interval how often the AudioActivity of Outputs is dispatched. The lower the value, the more accurate the indicator is at the cost of performance.
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:48
rmsDBFSInterval
rmsDBFSInterval:
number
Interval how often the AudioPowerLevel Event is dispatched.
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:38
Accessors
address
get
address():string
Returns
string
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:142
audioInputs
get
audioInputs():AudioInput
[]
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:187
audioOutputs
get
audioOutputs():AudioOutput
[]
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:175
cipher
get
cipher():Cipher
Returns
Cipher
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:140
customer
get
customer():string
Returns
string
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:149
gatewayAddress
get
gatewayAddress():string
Returns
string
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:141
id
get
id():string
The id of the room.
Returns
string
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:138
ownPeer
get
ownPeer():Peer
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:148
ownPeerId
get
ownPeerId():number
The id of the own peer.
Returns
number
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:146
peers
get
peers():Map
<number
,Peer
>
Returns
Map
<number
, Peer
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:147
position
get
position(): [number
,number
,number
]
The position of the own peer in the room.
Returns
[number
, number
, number
]
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:153
roomData
get
roomData():Uint8Array
Arbitrary data that could be set via the admin api.
Returns
Uint8Array
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:157
status
get
status():RoomStatus
The current state of the room stream connection.
set
status(state
):void
Update the connection state of the room.
Parameters
• state: RoomStatus
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:174
token
get
token():RoomToken
Returns
RoomToken
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:139
userData
get
userData():Uint8Array
Get the latest userData from the own peer.
set
userData(data
):void
Set the userData on the own peer.
Parameters
• data: Uint8Array
Returns
Uint8Array
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:166
videoOutputs
get
videoOutputs():VideoOutput
[]
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:176
volume
get
volume():Volume
Get the volume of the room.
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:170
Methods
addAudioInput()
addAudioInput(
input
):Promise
<void
>
Adds an AudioInput to the room to send audio.
Parameters
• input: AudioInput
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:199
addEventListener()
addEventListener<
OdinEventType
>(eventName
,handler
,options
?):void
Type Parameters
• OdinEventType extends keyof RoomEvents
Parameters
• eventName: OdinEventType
• handler: RoomEvents
[OdinEventType
]
• options?: boolean
| AddEventListenerOptions
Returns
void
Inherited from
OdinEventTarget
.addEventListener
Defined in
Odin/odin-typescript/lib/utils/odin-event-target.d.ts:22
addVideoInput()
addVideoInput(
input
):Promise
<void
>
Experimental method to stream a videoStream
Parameters
• input: VideoInput
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:194
dispatchEvent()
dispatchEvent<
T
>(event
):void
Type Parameters
• T extends OdinEvent
<any
>
Parameters
• event: T
Returns
void
Inherited from
Defined in
Odin/odin-typescript/lib/utils/odin-event-target.d.ts:23
flushUserData()
flushUserData():
Promise
<void
>
Sends the userdata of the own peer over the network so other peers in the room getting this update.
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:234
getAudioOutputById()
getAudioOutputById(
mediaId
):AudioOutput
Parameters
• mediaId: number
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:188
getVideoOutputById()
getVideoOutputById(
mediaId
):VideoOutput
Parameters
• mediaId: number
Returns
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:189
join()
join(
token
,options
?):Promise
<void
>
Joins the room and resolves, once the join was completed.
Parameters
• token: string
• options?: JoinParams
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:229
leave()
leave(
reason
?):void
Parameters
• reason?: string
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:230
pauseMedia()
pauseMedia(
mediaId
):Promise
<void
>
Pauses a remote media on the audio server that was paused before. The MediaID can be found at the AudioOutput of a peer.
Parameters
• mediaId: number
Returns
Promise
<void
>
TODO
Add a pause method to peers.
TODO
Add method to pause by passing the AudioOutput instead of the MediaID.
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:256
removeAudioInput()
removeAudioInput(
input
):void
Removes an AudioInput from the room and stops sending.
Parameters
• input: AudioInput
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:204
removeEventListener()
removeEventListener<
OdinEventType
>(type
,callback
):void
Type Parameters
• OdinEventType extends keyof RoomEvents
Parameters
• type: string
| OdinEventType
• callback: EventListenerOrEventListenerObject
| RoomEvents
[OdinEventType
]
Returns
void
Inherited from
OdinEventTarget
.removeEventListener
Defined in
Odin/odin-typescript/lib/utils/odin-event-target.d.ts:24
removeVideoInput()
removeVideoInput(
input
):void
Removes an VideoInput from the room and stops streaming.
Parameters
• input: VideoInput
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:209
request()
request<
Name
>(name
,properties
):Promise
<void
>
Type Parameters
• Name extends "Hello"
| "UpdatePeer"
| "StartMedia"
| "StopMedia"
| "PauseMedia"
| "ResumeMedia"
| "SetPeerPosition"
| "SendMessage"
Parameters
• name: Name
• properties: TypeOf
<object
[Name
]["request"
]>
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:235
resumeMedia()
resumeMedia(
mediaId
):Promise
<void
>
Resumes a remote media on the audio server that was paused before. The MediaID can be found at the AudioOutput of a peer.
Parameters
• mediaId: number
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:248
sendMessage()
sendMessage(
message
,targetPeerIds
?):Promise
<void
>
Sends a message with arbitrary data to all peers in the room or optionally to a list of specified peers.
Parameters
• message: Uint8Array
Byte array of arbitrary data to send
• targetPeerIds?: number
[]
Optional list of target peer IDs
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:242
setAudioOutputDevice()
setAudioOutputDevice(
device
?):Promise
<void
>
Sets the audio output device. IMPORTANT: Currently, the same audio output is used across all rooms (in the same plugin that was used).
Parameters
• device?: DeviceParameters
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:215
setPosition()
setPosition(
offsetX
,offsetY
,offsetZ
):Promise
<void
>
Updates the two-dimensional position of our own Peer
in the room to apply server-side culling.
Parameters
• offsetX: number
• offsetY: number
• offsetZ: number
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:223
setVolume()
setVolume(
value
):Promise
<void
>
Sets the volume of all AudioOutputs in the room.
Parameters
• value: Volume
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:181
startVideoOutput()
startVideoOutput(
output
):Promise
<void
>
Starts the VideoOutput. After the VideoOutput was started, its MediaStream will be available.
Parameters
• output: VideoOutput
Returns
Promise
<void
>
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:286
stopVideoOutput()
stopVideoOutput(
output
):void
Stops the VideoOutput. After the VideoOutput was stopped, its MediaStream will be removed.
Parameters
• output: VideoOutput
Returns
void
Defined in
Odin/odin-typescript/lib/api/room/index.d.ts:291