Skip to main content
Version: 2.x

Class OdinClient

Client Wrapper for ODIN ffi OdinNative.Core.Imports.NativeLibraryMethods

Declaration
public class OdinClient : MarshalByRefObject, IDisposable

Inheritance: System.Object -> System.MarshalByRefObject

Implements:
System.IDisposable

Properties​

Rooms​

A collection of all OdinNative.Wrapper.Room.Room

Declaration
public RoomCollection Rooms { get; }

Sockets​

A collection of all OdinNative.Wrapper.Socket.Socket

Declaration
public SocketCollection Sockets { get; }

EndPoint​

Connection EndPoint of the client.

Declaration
public Uri EndPoint { get; }

AccessKey​

Client AccessKey for all new rooms.

Declaration
public string AccessKey { get; }

UserData​

Declaration
public IUserData UserData { get; }

Methods​

Create(Uri)​

Creates a new initialized instance for ODIN ffi C# Wrapper

Declaration
public static OdinClient Create(Uri server)
Returns​

OdinNative.Wrapper.OdinClient: OdinClient wrapper

Parameters​
TypeNameDescription
System.UriserverOdin Server/Gateway

Create(Uri, string)​

Creates a new initialized instance for ODIN ffi C# Wrapper

Declaration
public static OdinClient Create(Uri server, string accessKey)
Returns​

OdinNative.Wrapper.OdinClient: OdinClient wrapper

Parameters​
TypeNameDescription
System.UriserverOdin Server
System.StringaccessKeyOdin access key

OnNativeDatagramReceived(nint, uint, ulong, nint, uint, nint)​

Declaration
protected static void OnNativeDatagramReceived(nint room_id, uint peer_id, ulong channel_mask, nint bytesPtr, uint bytes_length, nint user_data)
Parameters​
TypeName
System.IntPtrroom_id
System.UInt32peer_id
System.UInt64channel_mask
System.IntPtrbytesPtr
System.UInt32bytes_length
System.IntPtruser_data

OnNativeRPCReceived(nint, string, nint)​

Declaration
protected static void OnNativeRPCReceived(nint room_id, string json, nint user_data)
Parameters​
TypeName
System.IntPtrroom_id
System.Stringjson
System.IntPtruser_data

OnNativeSocketReceived(nint, nint, uint, nint)​

Declaration
protected static void OnNativeSocketReceived(nint socket_id, nint bytesPtr, uint bytes_length, nint user_data)
Parameters​
TypeName
System.IntPtrsocket_id
System.IntPtrbytesPtr
System.UInt32bytes_length
System.IntPtruser_data

ReloadLibrary(bool)​

Internal library reload

Declaration
protected void ReloadLibrary(bool init = true)
Parameters​
TypeNameDescription
System.BooleaninitIndicates to initialize the library again after release

CreateAccessKey()​

Create an example access key that can be registered on 4Players (see https://developers.4players.io/odin/)

Declaration
public static string CreateAccessKey()
Returns​

System.String: access key string or empty

CreateToken(string, string)​

Create an example token to join a room. For production use a token server!

Declaration
public static string CreateToken(string accesskey, string body)
Returns​

System.String: token string or empty

Parameters​
TypeNameDescription
System.StringaccesskeyKey to generate a token from
System.Stringbodytoken body

GenerateToken(string, out string)​

Create an example token to join a room. For production use a token server!

Declaration
public bool GenerateToken(string body, out string token)
Returns​

System.Boolean: true on success or false

Parameters​
TypeNameDescription
System.Stringbodytoken body
System.Stringtokentoken string

CreateRoom(uint, bool)​

Create a room for the set gateway.

Declaration
public Room CreateRoom(uint samplerate, bool stereo)
Returns​

OdinNative.Wrapper.Room.Room: Room object with a connection

Parameters​
TypeNameDescription
System.UInt32samplerateroom default samplerate fallback
System.Booleanstereoroom default stereo flag fallback

CloseRoom(ulong)​

Close a room by Id

Declaration
public bool CloseRoom(ulong roomId)
Returns​

System.Boolean: true on success or false

Parameters​
TypeNameDescription
System.UInt64roomIdroom id

CloseRoom(Room)​

Close a room

Declaration
public bool CloseRoom(Room room)
Returns​

System.Boolean: true on success or false

Parameters​
TypeNameDescription
OdinNative.Wrapper.Room.Roomroomroom to close

FreeRoom(ulong)​

Close and remove a room by Id

Declaration
public bool FreeRoom(ulong roomId)
Returns​

System.Boolean: true on success or false

Parameters​
TypeNameDescription
System.UInt64roomIdroom id

FreeRoom(Room)​

Close and remove a room

Declaration
public bool FreeRoom(Room room)
Returns​

System.Boolean: true on success or false

Parameters​
TypeNameDescription
OdinNative.Wrapper.Room.Roomroomroom

BroadcastSendMessage(string)​

Send a message to all rooms with the default encoding UTF8

Declaration
public void BroadcastSendMessage(string message)
Parameters​
TypeNameDescription
System.StringmessageUTF8 string

CloseRooms()​

Completely closes all OdinNative.Wrapper.Room.Room associated.

Declaration
public void CloseRooms()

FreeRooms()​

Free all OdinNative.Wrapper.Room.Room associated.

Declaration
public void FreeRooms()

Dispose(bool)​

On dispose will free all OdinNative.Wrapper.Room.Room associated

Declaration
protected virtual void Dispose(bool disposing)
Parameters​
TypeNameDescription
System.BooleandisposingIndicates to dispose managed resources

~OdinClient()​

Finalizer

Declaration
protected ~OdinClient()

Dispose()​

On dispose will free all OdinNative.Wrapper.Room.Room associated

Declaration
public void Dispose()

Implements​

  • System.IDisposable