Skip to main content
Version: 2.x

Class OdinPeer

Wrapper class of OdinNative.Wrapper.PeerEntity for Unity

This convenient class provides dispatching of events to Unity with passthrough as well as predefined helper functions to cover for a default usecases where the voice chat is visually and logical represented Unity gameobject that are manageable with the Unity editor.

Default Unity GameObject altering event callback functions:

  • OdinNative.Unity.OdinPeer.Peer_MediaAdded(System.Object,MediaAddedEventArgs) Creates GameObject with OdinNative.Unity.OdinMedia component and attach media
  • OdinNative.Unity.OdinPeer.Peer_MediaRemoved(System.Object,MediaRemovedEventArgs) Destroy GameObject with OdinNative.Unity.OdinMedia component

Assembly: cs.temp.dll.dll
Declaration
public class OdinPeer : MonoBehaviour, IPeer

Implements:
Odin.IPeer

Properties

Parent

Declaration
public IRoom Parent { get; set; }

Id

Declaration
public ulong Id { get; set; }

UserId

Declaration
public string UserId { get; }

UserData

Declaration
public IUserData UserData { get; }

Fields

OnMediaAdded

Additional event redirect from OdinNative.Unity.OdinRoom

Declaration
public MediaAddedProxy OnMediaAdded

OnMediaRemoved

Additional event redirect from OdinNative.Unity.OdinRoom

Declaration
public MediaRemovedProxy OnMediaRemoved

Methods

GetBasePeer()

Declaration
public PeerEntity GetBasePeer()
Returns

Odin.PeerEntity

GetRoomApi()

Declaration
public Room GetRoomApi()
Returns

Odin.Room

Peer_MediaAdded(object, MediaAddedEventArgs)

Event trigger to create a OdinNative.Unity.OdinMedia component

Declaration
public virtual void Peer_MediaAdded(object sender, MediaAddedEventArgs args)
Parameters
TypeNameDescription
System.ObjectsenderOdinRoom object
Odin.MediaAddedEventArgsargsstarted media data

AddMediaComponent(GameObject, ushort, bool)

Create a OdinNative.Unity.OdinMedia component

Declaration
public OdinMedia AddMediaComponent(GameObject containerObject, ushort mediaId, bool enable = true)
Returns

OdinNative.Unity.OdinMedia: created component

Parameters
TypeNameDescription
Odin.GameObjectcontainerObjectgameobject where the component will be added
System.UInt16mediaIdid of OdinNative.Wrapper.MediaDecoder
System.Booleanenableflag if the new OdinNative.Unity.OdinMedia component is enabled

AddMediaComponent(GameObject, ushort, uint, bool, bool)

Create a OdinNative.Unity.OdinMedia component

Declaration
public OdinMedia AddMediaComponent(GameObject containerObject, ushort mediaId, uint samplerate, bool stereo, bool enable = true)
Returns

OdinNative.Unity.OdinMedia: created component

Parameters
TypeNameDescription
Odin.GameObjectcontainerObjectgameobject where the component will be added
System.UInt16mediaIdid of OdinNative.Wrapper.MediaDecoder
System.UInt32sampleratedecoder samplerate
System.Booleanstereodecoder channel flag
System.Booleanenableflag if the new OdinNative.Unity.OdinMedia component is enabled

Peer_MediaRemoved(object, MediaRemovedEventArgs)

Event trigger to remove a OdinNative.Unity.OdinMedia component

Declaration
public virtual void Peer_MediaRemoved(object sender, MediaRemovedEventArgs args)
Parameters
TypeNameDescription
System.ObjectsenderOdinRoom object
Odin.MediaRemovedEventArgsargsstopped media data

RemoveMediaComponent(GameObject, ushort, bool)

Removes all child components with the same media id

Declaration
public bool RemoveMediaComponent(GameObject containerObject, ushort mediaId, bool componentOnly = false)
Returns

System.Boolean: true on removed decoder or false

Parameters
TypeNameDescription
Odin.GameObjectcontainerObjectchild components
System.UInt16mediaIddecoder id
System.BooleancomponentOnlyon false will destroy gameobject

Implements

  • Odin.IPeer