Skip to main content
Version: 2.x

Class OdinSocket

Wrapper class of OdinNative.Wrapper.Socket.Socket 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.

Declaration
[HelpURL("https://docs.4players.io/voice/unity/next/api/OdinNative.Unity/OdinSocket/")]
[AddComponentMenu("Odin/Instance/OdinSocket")]
public class OdinSocket : MonoBehaviour, ISocket

Inheritance: System.Object -> UnityEngine.Object -> UnityEngine.Component -> UnityEngine.Behaviour -> UnityEngine.MonoBehaviour

Implements:
OdinNative.Wrapper.ISocket

Properties​

Id​

Native socket id, 0 until the socket is registered in the room

Declaration
public ulong Id { get; }

Parent​

Default value null indicates root or not set

Declaration
public IPeer Parent { get; set; }

Room​

Declaration
public IRoom Room { get; set; }

Handle​

Declaration
public OdinSocketHandle Handle { get; }

IsRemote​

Indicates whether the socket was opened by the remote side (inbound)

Declaration
public bool IsRemote { get; }

Fields​

Declaration
public OdinRoom RoomLink
Declaration
public int PeerLink

Kind​

Declaration
public NativeBindings.OdinSocketKind Kind

Label​

Declaration
public int Label

Priority​

Declaration
public int Priority

OnMessageReceived​

Event OdinNative.Wrapper.Socket.Socket.OnMessageReceived redirected as Unity event

Declaration
public SocketMessageReceivedProxy OnMessageReceived

Methods​

GetRoomApi()​

Declaration
public Room GetRoomApi()
Returns​

OdinNative.Wrapper.Room.Room

GetBaseSocket<T>()​

Get the underlying OdinNative.Wrapper.Socket.Socket

Declaration
public T GetBaseSocket<T>() where T : ISocket
Returns​

<T>: native wrapper socket

Type Parameters​
  • T

OnSocket(IRoom, SocketMessageEventArgs)​

Declaration
public void OnSocket(IRoom room, SocketMessageEventArgs args)
Parameters​
TypeName
OdinNative.Wrapper.IRoomroom
OdinNative.Wrapper.Socket.SocketMessageEventArgsargs

Socket_MessageReceived(object, SocketMessageEventArgs)​

Default handler that logs received socket messages

Declaration
public virtual void Socket_MessageReceived(object sender, SocketMessageEventArgs args)
Parameters​
TypeNameDescription
System.ObjectsenderOdinSocket object
OdinNative.Wrapper.Socket.SocketMessageEventArgsargssocket message data

_Socket_OnMessageReceived(object, IRoom, byte[])​

Declaration
public virtual void _Socket_OnMessageReceived(object sender, IRoom room, byte[] message)
Parameters​
TypeName
System.Objectsender
OdinNative.Wrapper.IRoomroom
System.Byte[]message

Implements​