Class OdinRoom
Wrapper class of OdinNative.Wrapper.Room.Room for Unity.
This convenient class provides dispatching of events to Unity with passthrough UnityEngine.Events.UnityEvent
as well as predefined helper functions to cover default use cases where the voice chat is visually and logically represented by
Unity gameobjects that are manageable with the Unity editor like Context menu, Inspector and/or Hierarchy window.
Default Unity GameObject altering event callback functions:
OdinNative.Unity.OdinRoom.PeerJoinedCreateComponent(System.Object,OdinNative.Wrapper.Room.PeerJoinedEventArgs)Creates GameObject with OdinNative.Unity.OdinPeer componentOdinNative.Unity.OdinRoom.PeerLeftRemoveComponent(System.Object,OdinNative.Wrapper.Room.PeerLeftEventArgs)Destroy GameObject with OdinNative.Unity.OdinPeer componentOdinNative.Unity.OdinRoom.RoomStatusState(System.Object,OdinNative.Wrapper.Room.RoomStateChangedEventArgs)Destroy this components GameObject if the connection is closed i.e cleanup
Inheritance: System.Object -> UnityEngine.Object -> UnityEngine.Component -> UnityEngine.Behaviour -> UnityEngine.MonoBehaviour
Implements:
OdinNative.Wrapper.IRoom
Properties
Samplerate
Unity samplerate
OutputSampleRate
Playback samplerate reported by Unity, or OdinNative.Unity.OdinRoom.DefaultSampleRate when the Unity audio engine is disabled.
IsStereo
Unity channel flag
Id
Odin room id
CryptoCipher
Encryption handle container
Parent
Default value gameObject parent or Unity root
IsJoined
Indicates whether the room is currently joined
Self
The local peer for this client in this room. Null until the room is joined.
Fields
Gateway
Odin endpoint server
Token
Odin room token
InitialUserData
User data of the local peer that is sent together with the join request
AudioMixerGroup
Unity mixer
DefaultSampleRate
Fallback samplerate for setups that run without the Unity audio engine.
PeerPrefab
Prefab instantiated per joining peer. Falls back to a blank GameObject when null.
CryptoComponent
Odin Crypto cipher component
AutoCreateMedia
Automatically create default medias: an input encoder when audio is pushed via OdinNative.Unity.OdinRoom.ProxyAudio(System.Single[],System.Int32,System.Boolean)
and a decoder when audio arrives from a peer that has no decoder with a matching listen channel mask.
AutoDecoderMediaId
Media id used for default medias created by OdinNative.Unity.OdinRoom.AutoCreateMedia
OnRoomJoined
Event OdinNative.Wrapper.Room.Room.OnRoomJoined redirected as Unity event
OnDecoderAdded
Event raised when a decoder is added for a peer, redirected as Unity event
OnDecoderRemoved
Event raised when a decoder is removed for a peer, redirected as Unity event
OnPeerJoined
Event OdinNative.Wrapper.Room.Room.OnPeerJoined redirected as Unity event
OnPeerLeft
Event OdinNative.Wrapper.Room.Room.OnPeerLeft redirected as Unity event
OnMessageReceived
Event OdinNative.Wrapper.Room.Room.OnMessageReceived redirected as Unity event
OnRoomStateChanged
Event OdinNative.Wrapper.Room.Room.OnRoomStatusChanged redirected as Unity event
Methods
GetBaseRoom<T>()
Odin base room
Returns
<T>: wrapper room object
Type Parameters
T
SendAudio(float[], MediaEncoder)
Push audio samples to the room via a specific encoder.
Returns
System.Boolean
Parameters
| Type | Name |
|---|---|
System.Single[] | samples |
| OdinNative.Wrapper.MediaEncoder | encoder |
SendAudio(float[], MediaEncoder, bool)
Push audio samples to the room via a specific encoder with a silence flag.
Returns
System.Boolean
Parameters
| Type | Name |
|---|---|
System.Single[] | samples |
| OdinNative.Wrapper.MediaEncoder | encoder |
System.Boolean | isSilent |
Room_OnAutoCreateDecoder(object, DatagramEventArgs)
Creates a default decoder for a peer on incoming audio if the peer has no decoder with a matching listen channel mask.
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | Room object |
| OdinNative.Wrapper.Room.DatagramEventArgs | args | datagram data |
Room_OnDatagram(object, DatagramEventArgs)
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Room.DatagramEventArgs | args |
Room_OnRpc(object, RpcEventArgs)
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Room.RpcEventArgs | args |
Room_OnSocket(object, SocketMessageEventArgs)
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Socket.SocketMessageEventArgs | args |
Room_OnMessageReceived(object, uint, byte[])
Parameters
| Type | Name |
|---|---|
System.Object | sender |
System.UInt32 | peerId |
System.Byte[] | message |
ExtraOnNativeDecoderCreated(object, uint, ulong)
Called by OdinNative.Wrapper.Room.Room when the native SDK creates a decoder for a peer
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | Room object |
System.UInt32 | peerId | peer that started streaming |
System.UInt64 | mediaId | media id of the created decoder |
DecoderAddedPeerCreateComponent(object, DecoderAddedEventArgs)
Dispatches OdinNative.Unity.OdinRoom.OnDecoderAdded to the matching OdinNative.Unity.OdinPeer
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | OdinRoom object |
| OdinNative.Unity.Events.DecoderAddedEventArgs | args | decoder data |
ExtraOnNativeDecoderRemoved(object, uint, ulong)
Called by OdinNative.Wrapper.Room.Room when the native SDK removes a decoder for a peer
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | Room object |
System.UInt32 | peerId | peer that stopped streaming |
System.UInt64 | mediaId | media id of the removed decoder |
DecoderRemovedPeerRemoveComponent(object, DecoderRemovedEventArgs)
Dispatches OdinNative.Unity.OdinRoom.OnDecoderRemoved to the matching OdinNative.Unity.OdinPeer
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | OdinRoom object |
| OdinNative.Unity.Events.DecoderRemovedEventArgs | args | decoder data |
Room_OnRoomJoined(object, JoinedObjectContainer)
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Room.Rpc.JoinedObjectContainer | args |
Room_OnPeerLeft(object, PeerLeftObjectContainer)
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Peer.Rpc.PeerLeftObjectContainer | args |
PeerLeftRemoveComponent(object, PeerLeftEventArgs)
Removes all child components with the same peer id
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | OdinRoom object |
| OdinNative.Wrapper.Room.PeerLeftEventArgs | args | left peer data |
RemovePeerComponent(GameObject)
Remove a OdinNative.Unity.OdinPeer from a gameobject
Parameters
| Type | Name |
|---|---|
UnityEngine.GameObject | containerObject |
Room_OnPeerJoined(object, PeerJoinedObjectContainer)
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.Peer.Rpc.PeerJoinedObjectContainer | args |
PeerJoinedCreateComponent(object, PeerJoinedEventArgs)
Add a new GameObject with a new OdinNative.Unity.OdinPeer component. Uses OdinNative.Unity.OdinRoom.PeerPrefab if set.