Skip to main content
Version: 2.x

Class OdinClient

Client Wrapper for ODIN ffi OdinNative.Core.OdinLibrary.NativeMethods

Assembly: cs.temp.dll.dll
Declaration
public class OdinClient : MarshalByRefObject, IDisposable

Implements:
Odin.IDisposable

Properties

Rooms

A collection of all OdinNative.Wrapper.Room.Room

Declaration
public RoomCollection Rooms { get; }

EndPoint

Connection EndPoint. Default from OdinEditorConfig.

Declaration
public Uri EndPoint { get; }

AccessKey

Client AccessKey for all new rooms. Default from OdinHandler config.

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
Odin.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
Odin.UriserverOdin Server
System.StringaccessKeyOdin access key

Create(Uri, string, OdinConnectionPoolSettings)

Creates a new initialized instance for ODIN ffi C# Wrapper

Declaration
public static OdinClient Create(Uri server, string accessKey, NativeBindings.OdinConnectionPoolSettings settings)
Returns

OdinNative.Wrapper.OdinClient: OdinClient wrapper

Parameters
TypeNameDescription
Odin.UriserverOdin Server
System.StringaccessKeyOdin access key
Odin.NativeBindings.OdinConnectionPoolSettingssettingsCustom settings

OnNativeDatagramReceived(ulong, ushort, IntPtr, uint, MarshalByRefObject)

Declaration
protected static void OnNativeDatagramReceived(ulong room_id, ushort media_id, IntPtr bytesPtr, uint bytes_length, MarshalByRefObject user_data)
Parameters
TypeName
System.UInt64room_id
System.UInt16media_id
Odin.IntPtrbytesPtr
System.UInt32bytes_length
Odin.MarshalByRefObjectuser_data

OnNativeRPCReceived(ulong, IntPtr, uint, MarshalByRefObject)

Declaration
protected static void OnNativeRPCReceived(ulong room_id, IntPtr bytesPtr, uint bytes_length, MarshalByRefObject user_data)
Parameters
TypeName
System.UInt64room_id
Odin.IntPtrbytesPtr
System.UInt32bytes_length
Odin.MarshalByRefObjectuser_data

ReloadLibrary(bool)

Internal library reload

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

CreateAccessKey()

Create a 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 a 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 a 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

JoinRoom(string, uint, bool, bool)

Create and join a OdinNative.Wrapper.Room.Room

Declaration
public Room JoinRoom(string token, uint samplerate, bool stereo, bool handleRoom = true)
Returns

OdinNative.Wrapper.Room.Room: room or null

Parameters
TypeNameDescription
System.Stringtokentoken
System.UInt32samplerate
System.Booleanstereo
System.BooleanhandleRoomtrue will add the room to OdinNative.Wrapper.Room.RoomCollection of the client

JoinRoom(string, string, byte[], float, float, float, uint, bool, bool)

Create and join a OdinNative.Wrapper.Room.Room

Declaration
public Room JoinRoom(string token, string roomName, byte[] userData, float positionX, float positionY, float positionZ, uint samplerate, bool stereo, bool handleRoom = true)
Returns

OdinNative.Wrapper.Room.Room: room or null

Parameters
TypeNameDescription
System.Stringtokentoken
System.StringroomNameroom alias
System.Byte[]userDatainitial userdata
System.SinglepositionXserver culling position X
System.SinglepositionYserver culling position Y
System.SinglepositionZ
System.UInt32samplerate
System.Booleanstereo
System.BooleanhandleRoomtrue will add the room to OdinNative.Wrapper.Room.RoomCollection of the client

Join(Room, string)

Join a object of base OdinNative.Wrapper.Room.Room

Declaration
public bool Join(Room room, string token)
Returns

System.Boolean

Parameters
TypeNameDescription
OdinNative.Wrapper.Room.Roomroombase type OdinNative.Wrapper.Room.Room
System.Stringtoken

Join(Room, string, string, byte[], float, float)

Join a object of base OdinNative.Wrapper.Room.Room

Declaration
public bool Join(Room room, string token, string roomName, byte[] userData, float positionX, float positionY)
Returns

System.Boolean: room or null

Parameters
TypeNameDescription
OdinNative.Wrapper.Room.Roomroombase type OdinNative.Wrapper.Room.Room
System.Stringtokentoken
System.StringroomNameroom alias
System.Byte[]userDatainitial userdata
System.SinglepositionXserver culling position X
System.SinglepositionYserver culling position Y

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
TypeName
OdinNative.Wrapper.Room.Roomroom

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 and

Declaration
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIndicates to dispose the library

~OdinClient()

Default deconstructor

Declaration
protected ~OdinClient()

Dispose()

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

Declaration
public void Dispose()

Implements

  • Odin.IDisposable