Class Socket
An ODIN socket, which handles the underlying native opaque socket handle. This abstraction provides a high-level interface for sending and receiving messages to and from a peer.
Implements:
OdinNative.Wrapper.ISocket, System.IDisposable
Properties
Id
Socket id
Info
Label
Socket label
IsRemote
Socket ownership check
IsClosed
IsClosed
Parent
Default value null indicates root or not set
Room
Methods
OnSocket(IRoom, SocketMessageEventArgs)
Forward on socket data
Parameters
| Type | Name |
|---|---|
| OdinNative.Wrapper.IRoom | room |
| OdinNative.Wrapper.Socket.SocketMessageEventArgs | args |
Create(IRoom, OdinSocketKind, uint, int, int)
Initialise and opens a socket
Returns
OdinNative.Wrapper.Socket.Socket: Socket object
Parameters
| Type | Name | Description |
|---|---|---|
| OdinNative.Wrapper.IRoom | room | Room to open the socket in |
| OdinNative.Core.Imports.NativeBindings.OdinSocketKind | kind | Type of socket to open |
System.UInt32 | targetPeerId | remote peer id |
System.Int32 | label | socket name |
System.Int32 | priority | socket priority |
GetBaseSocket<T>()
This will always return itself
Returns
<T>
Type Parameters
T
RefreshHandle(int)
Refresh the native socket handle and pull socket info
Returns
System.Boolean: true on new handle
Parameters
| Type | Name | Description |
|---|---|---|
System.Int32 | peerId | default (-1) uses the last remote peer id |
Socket_OnMessageReceived(object, IRoom, byte[])
Parameters
| Type | Name |
|---|---|
System.Object | sender |
| OdinNative.Wrapper.IRoom | room |
System.Byte[] | message |
Open(OdinSocketKind, uint, int, int)
Returns
System.Boolean
Parameters
| Type | Name |
|---|---|
| OdinNative.Core.Imports.NativeBindings.OdinSocketKind | kind |
System.UInt32 | targetPeerId |
System.Int32 | label |
System.Int32 | priority |
GetSocketId()
Retrieves the socket id
Returns
System.UInt64: socket id
GetSocketInfo()
Returns
OdinNative.Core.Imports.NativeBindings.OdinSocketInfo
Send(string)
Sends an utf8 string message to the peer
Returns
OdinNative.Core.Imports.NativeBindings.OdinError: OdinError
Parameters
| Type | Name | Description |
|---|---|---|
System.String | message | text message |
Send(byte[])
Sends an arbitrary message to the peer
Returns
OdinNative.Core.Imports.NativeBindings.OdinError: OdinError
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte[] | message | arbitrary message |
Reset()
Close the native socket. (native dispose) Therefore local socket can not send.
Dispose(bool)
On dispose will close the socket
Parameters
| Type | Name |
|---|---|
System.Boolean | disposing |
~Socket()
Finalizer
Dispose()
On dispose will free the socket and all associated data
Events
OnMessageReceived
Odin socket received message
Event Type
OdinNative.Wrapper.OnSocketMessageReceivedDelegate
Implements
- OdinNative.Wrapper.ISocket
System.IDisposable