Class Room
An ODIN room, which handles the underlying native opaque room handle. This abstraction provides a high-level interface for joining rooms, managing persistent state.
Implements:
OdinNative.Wrapper.IRoom, System.IDisposable
Properties
Samplerate
Room default samplerate
Stereo
Room default stereo flag
EndPoint
Room server gateway endpoint
Id
RoomId
OwnPeerId
PeerId of self
UserId
UserId of self
Name
Room name
Customer
Joining customer
RoomStatus
RoomStatus
Tags
Self room tags
ReconnectToken
Latest token for new reconnects
InitialUserData
User data of the local peer that is sent together with the join request
IsJoined
IsJoined
IsClosed
IsClosed
CryptoCipher
Crypto cipher
RemotePeers
Container of room peers
Encoders
Container of room input medias
Sockets
Container of room sockets
Decoders
Elements of room output medias
Authentication
Room joining authentication
Parent
Default value null indicates root or not set
Self
The local peer for this client in this room. Null until the room is joined.
Methods
OnDatagramReceived(DatagramEventArgs)
Parameters
| Type | Name |
|---|---|
| OdinNative.Wrapper.Room.DatagramEventArgs | e |
OnRPCReceived(RpcEventArgs)
Parameters
| Type | Name |
|---|---|
| OdinNative.Wrapper.Room.RpcEventArgs | e |
OnSocketReceived(SocketMessageEventArgs)
Parameters
| Type | Name |
|---|---|
| OdinNative.Wrapper.Socket.SocketMessageEventArgs | e |
Create(string, uint, bool)
Initialise independent room
Returns
OdinNative.Wrapper.Room.Room: Room object
Parameters
| Type | Name | Description |
|---|---|---|
System.String | endPoint | Gateway server |
System.UInt32 | samplerate | sets default samplerate |
System.Boolean | stereo | sets default stereo flag |
Room_OnPeerLeft(object, PeerLeftObjectContainer)
Remove and dispose peer of OdinNative.Wrapper.Room.Room.RemotePeers
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Peer.Rpc.PeerLeftObjectContainer | args |
CreateMediaDecoder(uint)
Add new created decoder to OdinNative.Wrapper.Room.Room.RemotePeers by id returns decoder or null if there is no peer
Returns
OdinNative.Wrapper.MediaDecoder
Parameters
| Type | Name |
|---|---|
System.UInt32 | peerId |
RemoveMediaDecoder(uint, ulong)
Remove and dispose decoder of OdinNative.Wrapper.Room.Room.RemotePeers by media id
Parameters
| Type | Name |
|---|---|
System.UInt32 | peerId |
System.UInt64 | mediaId |
Room_OnPeerChanged(object, PeerChangedObjectContainer)
Set userdata of OdinNative.Wrapper.Room.Room.RemotePeers by id
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Peer.Rpc.PeerChangedObjectContainer | args |
Room_OnMessageReceived(object, uint, byte[])
Log message in Debug
Parameters
| Type | Name |
|---|---|
System.Object | sender |
System.UInt32 | peerId |
System.Byte[] | message |
Room_OnRoomJoined(object, JoinedObjectContainer)
Set OdinNative.Wrapper.Room.Room.RemotePeers for bookkeeping and AvailableEncoderIds for encoders
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Room.Rpc.JoinedObjectContainer | args |
Room_OnRoomLeft(object, string)
This close the current room
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | room |
System.String | reason | event reason |
Room_OnRoomStatusChanged(object, string)
Set the RoomStatus and flag for transition
Parameters
| Type | Name |
|---|---|
System.Object | sender |
System.String | connectionStatus |
Room_OnDatagram(object, DatagramEventArgs)
Default impl will push a datagram to the OdinNative.Wrapper.MediaDecoders of the sending peer whose OdinNative.Wrapper.MediaDecoder.ListenChannelMask overlaps the datagram's channel mask.
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | Room object |
| OdinNative.Wrapper.Room.DatagramEventArgs | args | Datagram event arguments |
Room_OnRPC(object, RpcEventArgs)
Default impl will process all rpc packets.
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | Room object |
| OdinNative.Wrapper.Room.RpcEventArgs | args | RPC event arguments |
Room_OnSocket(object, SocketMessageEventArgs)
Default impl will forward all socket messages.
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | Room object |
| OdinNative.Wrapper.Socket.SocketMessageEventArgs | args | RPC event arguments |
ProcessJsonRpc(string)
Parameters
| Type | Name |
|---|---|
System.String | json |
Join(string, string, uint, bool, OdinCipherHandle, out Room)
Create and join a Room
Returns
System.Boolean: true on successfully request join or false
Parameters
| Type | Name | Description |
|---|---|---|
System.String | endPoint | Gateway server |
System.String | auth | json authentication string |
System.UInt32 | samplerate | sets default samplerate |
System.Boolean | stereo | sets default stereo flag |
| OdinNative.Core.Imports.OdinCipherHandle | cipher | optional crypto or null |
| OdinNative.Wrapper.Room.Room | room | Initialized room |
Join(string, string, string, uint, bool, OdinCipherHandle, out Room)
Create and join a Room
Returns
System.Boolean: true on successfully request join or false
Parameters
| Type | Name | Description |
|---|---|---|
System.String | endPoint | Gateway server |
System.String | token | join token |
System.String | roomName | room name |
System.UInt32 | samplerate | sets default samplerate |
System.Boolean | stereo | sets default stereo flag |
| OdinNative.Core.Imports.OdinCipherHandle | cipher | optional crypto or null |
| OdinNative.Wrapper.Room.Room | room | Initialized room |
Join(string, string, OdinCipherHandle)
Join a room
Returns
System.Boolean: true on successfully request join or false
Parameters
| Type | Name | Description |
|---|---|---|
System.String | token | token for json authentication string |
System.String | roomName | room name for json authentication string |
| OdinNative.Core.Imports.OdinCipherHandle | cipher | optional crypto |
Join(string, OdinCipherHandle)
Join a room
Returns
System.Boolean: true on successfully request join or false
Parameters
| Type | Name | Description |
|---|---|---|
System.String | token | token for json authentication string |
| OdinNative.Core.Imports.OdinCipherHandle | cipher | optional crypto |
Create(string, OdinCipherHandle)
Join a room with a json authentication string
Returns
System.Boolean: true on successfully request join or false
Parameters
| Type | Name | Description |
|---|---|---|
System.String | authentication | Join token |
| OdinNative.Core.Imports.OdinCipherHandle | cipher | optional crypto cipher handle or null |
GetRoomId()
Retrieves the room id
Returns
System.UInt64: room id
GetRoomName(bool)
Retrieves the room name
Returns
System.String: room name
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | update | update this room name on true |
ResendUserData()
Resend native UserData
Returns
OdinNative.Core.Imports.NativeBindings.OdinError: error code
GetEncoder(ulong, out MediaEncoder)
Get an encoder from OdinNative.Wrapper.Room.Room.Encoders by id
Returns
System.Boolean: true on encoder found or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt64 | mediaId | id of an input media |
| OdinNative.Wrapper.MediaEncoder | encoder | input object |
GetOrCreateEncoder(out MediaEncoder)
Get an encoder from OdinNative.Wrapper.Room.Room.Encoders by id. If the encoder is not found create a new one that will be added to OdinNative.Wrapper.Room.Room.Encoders.
Returns
System.Boolean: true or false on error
Parameters
| Type | Name | Description |
|---|---|---|
| OdinNative.Wrapper.MediaEncoder | encoder | input object |
GetOrCreateEncoder(ulong, out MediaEncoder)
Get an encoder from OdinNative.Wrapper.Room.Room.Encoders by id. If the encoder is not found create a new one that will be added to OdinNative.Wrapper.Room.Room.Encoders.
Returns
System.Boolean: true or false on error
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt64 | mediaId | id of an input media |
| OdinNative.Wrapper.MediaEncoder | encoder | input object |
GetOrCreateEncoder(ulong, uint, bool, out MediaEncoder)
Get an encoder from OdinNative.Wrapper.Room.Room.Encoders by id. If the encoder is not found create a new one that will be added to OdinNative.Wrapper.Room.Room.Encoders.
Returns
System.Boolean: true or false on error
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt64 | mediaId | id of an input media |
System.UInt32 | samplerate | custom samplerate |
System.Boolean | stereo | custom stereo flag |
| OdinNative.Wrapper.MediaEncoder | encoder | input object |
CreateEncoder()
Create a new input media that will be added to OdinNative.Wrapper.Room.Room.Encoders
Returns
OdinNative.Wrapper.MediaEncoder: input media
CreateEncoder(uint, bool, uint)
Create a new input media that will be added to OdinNative.Wrapper.Room.Room.Encoders
Returns
OdinNative.Wrapper.MediaEncoder: input media
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | samplerate | custom samplerate |
System.Boolean | stereo | custom stereo flag |
System.UInt32 | peerId | binding peer id |
RemoveEncoder(ulong, out MediaEncoder)
Removes the input media from OdinNative.Wrapper.Room.Room.Encoders
Returns
System.Boolean: true on encoder found or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt64 | mediaId | id of an input media |
| OdinNative.Wrapper.MediaEncoder | encoder | input media that was removed |
GetDecoder(uint, ulong, out MediaDecoder)
Get a decoder from OdinNative.Wrapper.PeerEntity.Medias of OdinNative.Wrapper.Room.Room.RemotePeers by id
Returns
System.Boolean: true on decoder found or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | id of peer |
System.UInt64 | mediaId | id of output media |
| OdinNative.Wrapper.MediaDecoder | decoder | output object or null |
GetOrCreateDecoder(uint, ulong, out MediaDecoder)
Get a decoder from OdinNative.Wrapper.PeerEntity.Medias of OdinNative.Wrapper.Room.Room.RemotePeers by id. If the decoder is not found create a new one that will be added to the Peer
Returns
System.Boolean: true on decoder found or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | id of peer |
System.UInt64 | mediaId | id of output media |
| OdinNative.Wrapper.MediaDecoder | decoder | output object or null |
GetOrCreateDecoder(uint, ulong, uint, bool, out MediaDecoder)
Get a decoder from OdinNative.Wrapper.PeerEntity.Medias of OdinNative.Wrapper.Room.Room.RemotePeers by id. If the decoder is not found create a new one that will be added to the Peer
Returns
System.Boolean: true on decoder found or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | id of peer |
System.UInt64 | mediaId | id of output media |
System.UInt32 | samplerate | custom samplerate |
System.Boolean | stereo | custom stereo flag |
| OdinNative.Wrapper.MediaDecoder | decoder | output object or null |
CreateDecoder(uint)
Create a new output media that will be added to OdinNative.Wrapper.PeerEntity.Medias
Returns
OdinNative.Wrapper.MediaDecoder: output media
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | id of peer |
CreateDecoder(uint, uint, bool)
Create a new output media that will be added to OdinNative.Wrapper.PeerEntity.Medias
Returns
OdinNative.Wrapper.MediaDecoder: output media
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | id of peer |
System.UInt32 | samplerate | custom samplerate |
System.Boolean | stereo | custom stereo flag |
RemoveDecoder(uint, ulong, out MediaDecoder)
Removes an output media from a remote peer.
Returns
System.Boolean: true on decoder found or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | id of peer |
System.UInt64 | mediaId | id of an output media |
| OdinNative.Wrapper.MediaDecoder | decoder | output media that was removed |
SetListenChannelMask(ChannelMask)
Sets the channel mask used when listening to peers that do not have a per-peer override set
via OdinNative.Wrapper.Room.Room.SetListenChannelMaskForPeer(System.UInt32,OdinNative.Core.Utility.ChannelMask) . Applies immediately to every currently known peer
and is automatically (re-)applied to peers that join afterward.
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
| OdinNative.Core.Utility.ChannelMask | mask | channel mask to listen to for all peers without an override |
SetListenChannelMaskForPeer(uint, ChannelMask)
Overrides the channel mask used when listening to a specific peer, taking precedence over the default set via OdinNative.Wrapper.Room.Room.SetListenChannelMask(OdinNative.Core.Utility.ChannelMask).
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | peer to override the listen channel mask for |
| OdinNative.Core.Utility.ChannelMask | mask | channel mask to listen to for this peer |
ClearListenChannelMaskForPeer(uint)
Removes a previously set per-peer listen channel mask override, falling back to the default set via OdinNative.Wrapper.Room.Room.SetListenChannelMask(OdinNative.Core.Utility.ChannelMask) for that peer.
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt32 | peerId | peer to remove the override for |
SetChannelMasks(IDictionary<uint, ulong>, bool)
Sends a "SetChannelMasks" request to the server to control which channels should be
received from the specified peers.
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.Collections.Generic.IDictionary<System.UInt32,System.UInt64> | masks | peer id to channel mask mapping |
System.Boolean | reset | when true, replaces the server-side subscription instead of merging into it |
UpdateUserData(IUserData)
Update arbitrary userdata of self (note: OdinNative.Wrapper.UserData)
Returns
System.Boolean
Parameters
| Type | Name | Description |
|---|---|---|
| OdinNative.Wrapper.IUserData | userData | arbitrary data |
UpdateUserData(string)
Update userdata of self (note: OdinNative.Wrapper.Room.Room.UpdateUserData(OdinNative.Wrapper.IUserData))
Returns
System.Boolean
Parameters
| Type | Name | Description |
|---|---|---|
System.String | json | json data |
SendMessage(string)
Send a "message" rpc to the server to broadcast the message.
Returns
System.Boolean
Parameters
| Type | Name | Description |
|---|---|---|
System.String | message | UTF8 string |
SendRpc<T>(T)
Send rpc to the room as json representation
Returns
System.Boolean
Parameters
| Type | Name | Description |
|---|---|---|
<T> | obj | data to serialize |
Type Parameters
| Name | Description |
|---|---|
T | type |
SendRpc(string)
Send raw rpc to the room
Returns
OdinNative.Core.Imports.NativeBindings.OdinError
Parameters
| Type | Name | Description |
|---|---|---|
System.String | rpc | json representation string |
SendAudio(float[], bool)
Push the samples to all OdinNative.Wrapper.Room.Room.Encoders for pipeline processing and pop the result as datagrams to the server
Parameters
| Type | Name | Description |
|---|---|---|
System.Single[] | samples | Audio data |
System.Boolean | isSilent | flag these samples as silence |
SendAudio(float[], ulong, bool)
Push the samples to the input media for pipeline processing and pop the result as datagram to the server
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.Single[] | samples | Audio data |
System.UInt64 | mediaId | input media id |
System.Boolean | isSilent | flag these samples as silence |
SendAudio(float[], MediaEncoder)
Push the samples to the input media for pipeline processing and pop the result as datagram to the server
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.Single[] | samples | Audio data |
| OdinNative.Wrapper.MediaEncoder | encoder | input media |
SendAudio(float[], MediaEncoder, bool)
Push the samples to the input media for pipeline processing and pop the result as datagram to the server
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.Single[] | samples | Audio data |
| OdinNative.Wrapper.MediaEncoder | encoder | input media |
System.Boolean | isSilent | flag these samples as silence |
SendEncoderAudio(ushort)
Pop all samples from the input media by id and send them to the server
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
System.UInt16 | mediaId | input media id |
SendEncoderAudio(MediaEncoder)
Pop all samples from the input media and send them to the server
Returns
System.Boolean: true on success or false
Parameters
| Type | Name | Description |
|---|---|---|
| OdinNative.Wrapper.MediaEncoder | encoder | input media |
SendDatagram(byte[])
Send audio to the server
Returns
OdinNative.Core.Imports.NativeBindings.OdinError: OdinNative.Core.Imports.NativeBindings.OdinError.ODIN_ERROR_SUCCESS or error
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte[] | datagram | encoder datagram |
AddSocket(OdinSocketKind, uint, int, int)
Returns
OdinNative.Wrapper.Socket.Socket
Parameters
| Type | Name |
|---|---|
| OdinNative.Core.Imports.NativeBindings.OdinSocketKind | type |
System.UInt32 | peerId |
System.Int32 | label |
System.Int32 | priority |
GetSocket(ulong)
Returns
OdinNative.Wrapper.Socket.Socket
Parameters
| Type | Name |
|---|---|
System.UInt64 | Id |
GetOrAddSocket(uint, OdinSocketKind, uint, int, int)
Returns
OdinNative.Wrapper.Socket.Socket
Parameters
| Type | Name |
|---|---|
System.UInt32 | Id |
| OdinNative.Core.Imports.NativeBindings.OdinSocketKind | type |
System.UInt32 | peerId |
System.Int32 | label |
System.Int32 | priority |
RemoveSocket(ulong, bool)
Returns
OdinNative.Wrapper.Socket.Socket
Parameters
| Type | Name |
|---|---|
System.UInt64 | Id |
System.Boolean | close |
SendLoopbackRpc(string)
Send client side rpc message
Returns
OdinNative.Core.Imports.NativeBindings.OdinError: OdinNative.Core.Imports.NativeBindings.OdinError.ODIN_ERROR_SUCCESS or error
Parameters
| Type | Name | Description |
|---|---|---|
System.String | rpc | json string |
Close()
Close the native room. (native dispose)
Dispose(bool)
On dispose will free the room and all associated data
Parameters
| Type | Name |
|---|---|
System.Boolean | disposing |
~Room()
Finalizer
Dispose()
Requests close, then frees resources after Closed or a timeout and after active callbacks exit.
Events
OnDatagram
Call on audio data
Event Type
System.EventHandler<OdinNative.Wrapper.Room.DatagramEventArgs>
OnRpc
Call on rpc data
Event Type
System.EventHandler<OdinNative.Wrapper.Room.RpcEventArgs>
OnSocket
Call on socket data
Event Type
System.EventHandler<OdinNative.Wrapper.Socket.SocketMessageEventArgs>
OnRoomStatusChanged
Odin connection status
Event Type
OdinNative.Wrapper.OnRoomStatusChangedDelegate
OnRoomJoined
Odin room joined
Event Type
OdinNative.Wrapper.OnRoomJoinedDelegate
OnRoomLeft
Odin room left
Event Type
OdinNative.Wrapper.OnRoomLeftDelegate
OnPeerJoined
Odin peer joined
Event Type
OdinNative.Wrapper.OnPeerJoinedDelegate
OnPeerLeft
A remote peer left, or was removed locally when this session ended.
Event Type
OdinNative.Wrapper.OnPeerLeftDelegate
OnPeerChanged
Odin peer changed
Event Type
OdinNative.Wrapper.OnPeerChangedDelegate
OnMessageReceived
Odin room received message
Event Type
OdinNative.Wrapper.OnMessageReceivedDelegate
__OnExtraDestroyDelegate
Event Type
System.EventHandler<System.IntPtr>
Implements
- OdinNative.Wrapper.IRoom
System.IDisposable