Class OdinPeer
Wrapper class of OdinNative.Wrapper.PeerEntity 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.
Default Unity GameObject altering event callback functions:
OdinNative.Unity.OdinPeer.Peer_DecoderAdded(System.Object,OdinNative.Unity.Events.DecoderAddedEventArgs)Creates GameObject with OdinNative.Unity.OdinDecoder component and attach mediaOdinNative.Unity.OdinPeer.Peer_DecoderRemoved(System.Object,OdinNative.Unity.Events.DecoderRemovedEventArgs)Destroy GameObject with OdinNative.Unity.OdinDecoder component
Inheritance: System.Object -> UnityEngine.Object -> UnityEngine.Component -> UnityEngine.Behaviour -> UnityEngine.MonoBehaviour
Implements:
OdinNative.Wrapper.IPeer
Properties
Parent
Default value null indicates root or not set
Id
peer id
UserId
token user id
UserData
peer userdata
Tags
user tags
Fields
DecoderPrefab
Prefab instantiated per decoder.
OnDecoderAdded
Additional event redirect from OdinNative.Unity.OdinRoom
OnDecoderRemoved
Additional event redirect from OdinNative.Unity.OdinRoom
Methods
GetBasePeer()
Get the underlying OdinNative.Wrapper.PeerEntity
Returns
OdinNative.Wrapper.PeerEntity: native wrapper peer
GetRoomApi()
Get the underlying OdinNative.Wrapper.Room.Room
Returns
OdinNative.Wrapper.Room.Room: native wrapper room
GetEncoder()
Get encoder
Returns
OdinNative.Wrapper.MediaEncoder: input media encoder of the peer or null
GetDecoder()
Get decoder
Returns
OdinNative.Wrapper.MediaDecoder: output media decoder of the peer or null
Peer_DecoderAdded(object, DecoderAddedEventArgs)
Event trigger to create a OdinNative.Unity.OdinDecoder component
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | OdinRoom object |
| OdinNative.Unity.Events.DecoderAddedEventArgs | args | started media data |
AddDecoderComponent(GameObject, ulong, bool)
Create a OdinNative.Unity.OdinDecoder component
Returns
OdinNative.Unity.OdinDecoder: created component
Parameters
| Type | Name | Description |
|---|---|---|
UnityEngine.GameObject | containerObject | gameobject where the component will be added |
System.UInt64 | mediaId | id of OdinNative.Wrapper.MediaDecoder |
System.Boolean | enable | flag if the new OdinNative.Unity.OdinDecoder component is enabled |
AddDecoderComponent(GameObject, ulong, uint, bool, bool)
Create a OdinNative.Unity.OdinDecoder component
Returns
OdinNative.Unity.OdinDecoder: created component
Parameters
| Type | Name | Description |
|---|---|---|
UnityEngine.GameObject | containerObject | gameobject where the component will be added |
System.UInt64 | mediaId | id of OdinNative.Wrapper.MediaDecoder |
System.UInt32 | samplerate | decoder samplerate |
System.Boolean | stereo | decoder channel flag |
System.Boolean | enable | flag if the new OdinNative.Unity.OdinDecoder component is enabled |
Peer_DecoderRemoved(object, DecoderRemovedEventArgs)
Event trigger to remove a OdinNative.Unity.OdinDecoder component
Parameters
| Type | Name | Description |
|---|---|---|
System.Object | sender | OdinRoom object |
| OdinNative.Unity.Events.DecoderRemovedEventArgs | args | stopped media data |
Peer_MediaAdded(object, DecoderAddedEventArgs)
Forward for serialized UnityEvents of previous versions
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Unity.Events.DecoderAddedEventArgs | args |
Peer_MediaRemoved(object, DecoderRemovedEventArgs)
Forward for serialized UnityEvents of previous versions
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Unity.Events.DecoderRemovedEventArgs | args |
RemoveDecoderComponent(GameObject, ulong, bool)
Removes all child components with the same media id
Returns
System.Boolean: true on removed decoder or false
Parameters
| Type | Name | Description |
|---|---|---|
UnityEngine.GameObject | containerObject | child components |
System.UInt64 | mediaId | decoder id |
System.Boolean | componentOnly | on false will destroy gameobject |
AddSocketComponent(GameObject, OdinSocketKind, int, int)
Returns
Parameters
| Type | Name |
|---|---|
UnityEngine.GameObject | containerObject |
| OdinNative.Core.Imports.NativeBindings.OdinSocketKind | kind |
System.Int32 | label |
System.Int32 | priority |
RemoveSocketComponent(GameObject, ulong, bool)
Returns
System.Boolean
Parameters
| Type | Name |
|---|---|
UnityEngine.GameObject | containerObject |
System.UInt64 | socketId |
System.Boolean | componentOnly |