UOdinSocket
An opaque type representing an ODIN socket
- Header:
#include "OdinSocket.h" - Module:
Odin - Inherits from:
UObject - Blueprint: Blueprint type, Blueprintable · Blueprint reference
Sockets are bound to the current room session: they do not survive a reconnect, and sockets to a specific peer are closed automatically when that peer leaves the room.
Overview
Functions
| Name | Description |
|---|---|
ConstructSocket | Creates an empty socket object. |
ResetSocket | Closes the specified ODIN socket handle, therefore local socket can not send |
ResetOdinSocketByHandle | Resets the specified ODIN socket handle |
Create | Opens the socket in a room. |
GetRemotePeerId | Returns the peer on the other end of the socket, or 0 for a socket to all peers. |
GetSocketLabel | Returns the label the socket was created with. |
GetSocketNamedLabel | Returns the label the socket was created with, as a Name. |
GetSocketInfo | Returns information about the socket: room, kind, direction, remote peer, label, priority and the number of unsent bytes. |
Send | Sends a byte array to the peer (or peers) on the other end of the socket. |
SendString | Sends a string, encoded as UTF-8, to the peer (or peers) on the other end of the socket. |
IsReady | Checks socket and socket info. |
GetNativeHandle | |
GetHandle | |
InvalidateHandle | Drops the reference to the native socket without touching it (e.g. |
SetHandle |
Functions
ConstructSocket
Overload 1
Static · Blueprint: Construct Socket
Creates an empty socket object. Call Create Socket on it to open the socket in a room, or use Open Socket on the room, which does both.
| Parameter | Type | Description |
|---|---|---|
WorldContextObject | UObject* |
Returns UOdinSocket*
Overload 2
Static
| Parameter | Type | Description |
|---|---|---|
WorldContextObject | UObject* | |
handle | OdinSocket* |
Returns UOdinSocket*
ResetSocket
Blueprint: Reset Socket
Closes the specified ODIN socket handle, therefore local socket can not send
Returns bool
ResetOdinSocketByHandle
Static
Resets the specified ODIN socket handle
| Parameter | Type | Description |
|---|---|---|
socket | OdinSocket* |
Returns bool
Create
Blueprint: Create Socket
Opens the socket in a room.
| Parameter | Type | Description |
|---|---|---|
Room | UOdinRoom* | The room to open the socket in. |
SocketKind | EOdinSocketKind | Reliable or unreliable delivery. |
TargetPeerId | int64 | The receiving peer, or 0 for all peers in the room. |
Label | int32 | An arbitrary number the receivers can read with Get Label, e.g. to tell several sockets apart. |
Priority | int32 | Transport priority; 0 is the default, higher values are sent first. High values can impact voice quality. |
Returns UOdinSocket* – The socket itself. Check Is Ready before sending.
GetRemotePeerId
Blueprint: Get Remote Peer Id
Returns the peer on the other end of the socket, or 0 for a socket to all peers.
Returns int64
GetSocketLabel
Blueprint: Get Label
Returns the label the socket was created with.
Returns int32
GetSocketNamedLabel
Blueprint: Get Named Label
Returns the label the socket was created with, as a Name.
Returns FName
GetSocketInfo
Blueprint: Get Socket Info
Returns information about the socket: room, kind, direction, remote peer, label, priority and the number of unsent bytes.
Returns FOdinSocketInfo
Send
Blueprint: Send
Sends a byte array to the peer (or peers) on the other end of the socket.
| Parameter | Type | Description |
|---|---|---|
Message | TArray<uint8> | byte array |
Returns bool – true on ODIN_ERROR_SUCCESS or false
SendString
Blueprint: Send String
Sends a string, encoded as UTF-8, to the peer (or peers) on the other end of the socket.
| Parameter | Type | Description |
|---|---|---|
Message | const FString& | String Message |
Returns bool – true on ODIN_ERROR_SUCCESS or false
IsReady
Const · Blueprint: Is Ready
Checks socket and socket info. (extra socket info call)
Returns bool – true if this appears to be a valid object and unsent bytes are 0
GetNativeHandle
Const · Inline
Returns OdinSocket*
GetHandle
Const · Inline
Returns TWeakObjectPtr<UOdinHandle>
InvalidateHandle
Inline
Drops the reference to the native socket without touching it (e.g. after the owning room was freed).
SetHandle
Inline
| Parameter | Type | Description |
|---|---|---|
handle | OdinSocket* |
Events
OnSocketMessageReceivedBP
Blueprint: On Socket Message Received
Raised when a message arrives on this socket.
Signature: FOdinSocketReceivedDelegate void(UOdinRoom* room, UOdinSocket* socket, const TArray<uint8>& data) (multicast)