Nakama .NET 3.1.1
.NET client for Nakama server written in C
Nakama.Socket Class Reference

A socket which implements the Nakama realtime API. More...

Inheritance diagram for Nakama.Socket:
Nakama.ISocket

Public Member Functions

 Socket ()
 A new socket with default options. More...
 
 Socket (ISocketAdapter adapter)
 A new socket with an adapter. More...
 
 Socket (string scheme, string host, int port, ISocketAdapter adapter)
 A new socket with server connection and adapter options. More...
 
Task AcceptPartyMemberAsync (string partyId, IUserPresence presence)
 Accept a party member's request to join the party. More...
 
async Task< IMatchmakerTicketAddMatchmakerAsync (string query="*", int minCount=2, int maxCount=8, Dictionary< string, string > stringProperties=null, Dictionary< string, double > numericProperties=null)
 Join the matchmaker pool and search for opponents on the server. More...
 
async Task< IPartyMatchmakerTicketAddMatchmakerPartyAsync (string partyId, string query, int minCount, int maxCount, Dictionary< string, string > stringProperties=null, Dictionary< string, double > numericProperties=null)
 Begin matchmaking as a party. More...
 
Task CloseAsync ()
 Close the socket connection to the server. More...
 
Task ConnectAsync (ISession session, bool appearOnline=false, int connectTimeoutSec=DefaultConnectTimeout, string langTag="en")
 Connect to the server. More...
 
Task ClosePartyAsync (string partyId)
 End a party, kicking all party members and closing it. More...
 
async Task< IMatchCreateMatchAsync ()
 Create a multiplayer match on the server. More...
 
async Task< IPartyCreatePartyAsync (bool open, int maxSize)
 Create a party. More...
 
void Dispose ()
 Dispose will destroy the active socket and clean up all associated resources. More...
 
Task< IStatusFollowUsersAsync (IEnumerable< IApiUser > users)
 Subscribe to one or more users for their status updates. More...
 
async Task< IStatusFollowUsersAsync (IEnumerable< string > userIDs, IEnumerable< string > usernames=null)
 Subscribe to one or more users for their status updates. More...
 
async Task< IChannelJoinChatAsync (string target, ChannelType type, bool persistence=false, bool hidden=false)
 Join a chat channel on the server. More...
 
async Task< IMatchJoinMatchAsync (IMatchmakerMatched matched)
 Join a multiplayer match with the matchmaker matched object. More...
 
async Task< IMatchJoinMatchAsync (string matchId, IDictionary< string, string > metadata=null)
 Join a multiplayer match by ID. More...
 
Task JoinPartyAsync (string partyId)
 Join a party. More...
 
Task LeaveChatAsync (IChannel channel)
 Leave a chat channel on the server. More...
 
Task LeaveChatAsync (string channelId)
 Leave a chat channel on the server. More...
 
Task LeaveMatchAsync (IMatch match)
 Leave a multiplayer match on the server. More...
 
Task LeaveMatchAsync (string matchId)
 Leave a multiplayer match on the server. More...
 
Task LeavePartyAsync (string partyId)
 Leave the party. More...
 
async Task< IPartyJoinRequestListPartyJoinRequestsAsync (string partyId)
 Request a list of pending join requests for a party. More...
 
Task PromotePartyMemberAsync (string partyId, IUserPresence partyMember)
 Promote a new party leader. More...
 
Task< IChannelMessageAckRemoveChatMessageAsync (IChannel channel, string messageId)
 Remove a chat message from a chat channel on the server. More...
 
async Task< IChannelMessageAckRemoveChatMessageAsync (string channelId, string messageId)
 Remove a chat message from a chat channel on the server. More...
 
Task RemoveMatchmakerAsync (IMatchmakerTicket ticket)
 Leave the matchmaker pool with the ticket. More...
 
Task RemoveMatchmakerAsync (string ticket)
 Leave the matchmaker pool with the ticket contents. More...
 
Task RemoveMatchmakerPartyAsync (string partyId, string ticket)
 <inheritdoc="RemoveMatchmakerPartyAsync"/> More...
 
Task RemovePartyMemberAsync (string partyId, IUserPresence presence)
 <inheritdoc="RemovePartyMemberAsync"/> More...
 
async Task< IApiRpcRpcAsync (string funcId, string payload=null)
 Execute an RPC function to the server. More...
 
async Task< IApiRpcRpcAsync (string funcId, ArraySegment< byte > payload)
 Execute an RPC function to the server. More...
 
Task SendMatchStateAsync (string matchId, long opCode, ArraySegment< byte > state, IEnumerable< IUserPresence > presences=null)
 Send input to a multiplayer match on the server. More...
 
Task SendMatchStateAsync (string matchId, long opCode, string state, IEnumerable< IUserPresence > presences=null)
 Send input to a multiplayer match on the server. More...
 
Task SendMatchStateAsync (string matchId, long opCode, byte[] state, IEnumerable< IUserPresence > presences=null)
 Send input to a multiplayer match on the server. More...
 
Task SendPartyDataAsync (string partyId, long opCode, ArraySegment< byte > data)
 Send data to a party. More...
 
Task SendPartyDataAsync (string partyId, long opCode, string data)
 Send data to a party. More...
 
Task SendPartyDataAsync (string partyId, long opCode, byte[] data)
 Send data to a party. More...
 
override string ToString ()
 
Task UnfollowUsersAsync (IEnumerable< IApiUser > users)
 Unfollow one or more users from their status updates. More...
 
Task UnfollowUsersAsync (IEnumerable< string > userIDs)
 Unfollow one or more users from their status updates. More...
 
Task< IChannelMessageAckUpdateChatMessageAsync (IChannel channel, string messageId, string content)
 Update a chat message on a chat channel in the server. More...
 
async Task< IChannelMessageAckUpdateChatMessageAsync (string channelId, string messageId, string content)
 Update a chat message on a chat channel in the server. More...
 
Task UpdateStatusAsync (string status)
 Update the status for the current user online. More...
 
Task< IChannelMessageAckWriteChatMessageAsync (IChannel channel, string content)
 Send a chat message to a chat channel on the server. More...
 
async Task< IChannelMessageAckWriteChatMessageAsync (string channelId, string content)
 Send a chat message to a chat channel on the server. More...
 

Static Public Member Functions

static ISocket From (IClient client)
 Build a socket from a client object. More...
 
static ISocket From (IClient client, ISocketAdapter adapter)
 Build a socket from a client object and socket adapter. More...
 

Static Public Attributes

const int DefaultConnectTimeout = 30
 The default timeout for when the socket connects. More...
 

Properties

bool IsConnected [get]
 
bool IsConnecting [get]
 
ILogger Logger [getset]
 The logger to use with the socket. More...
 
- Properties inherited from Nakama.ISocket
bool IsConnected [get]
 If the socket is connected. More...
 
bool IsConnecting [get]
 If the socket is connecting. More...
 

Events

Action Closed
 
Action Connected
 
Action< IApiChannelMessageReceivedChannelMessage
 
Action< IChannelPresenceEventReceivedChannelPresence
 
Action< Exception > ReceivedError
 
Action< IMatchmakerMatchedReceivedMatchmakerMatched
 
Action< IMatchStateReceivedMatchState
 
Action< IMatchPresenceEventReceivedMatchPresence
 
Action< IApiNotificationReceivedNotification
 
Action< IStatusPresenceEventReceivedStatusPresence
 
Action< IStreamPresenceEventReceivedStreamPresence
 
Action< IStreamStateReceivedStreamState
 
Action< IPartyReceivedParty
 
Action< IPartyCloseReceivedPartyClose
 
Action< IPartyDataReceivedPartyData
 
Action< IPartyJoinRequestReceivedPartyJoinRequest
 
Action< IPartyLeaderReceivedPartyLeader
 
Action< IPartyPresenceEventReceivedPartyPresence
 
Action< IPartyMatchmakerTicketReceivedPartyMatchmakerTicket
 
- Events inherited from Nakama.ISocket
Action Closed
 Received when a socket is closed. More...
 
Action Connected
 Received when a socket is connected. More...
 
Action< IApiChannelMessageReceivedChannelMessage
 Received a chat channel message. More...
 
Action< IChannelPresenceEventReceivedChannelPresence
 Received a presence change for joins and leaves with users in a chat channel. More...
 
Action< Exception > ReceivedError
 Received when an error occurs on the socket. More...
 
Action< IMatchmakerMatchedReceivedMatchmakerMatched
 Received a matchmaker matched message. More...
 
Action< IMatchStateReceivedMatchState
 Received a message from a multiplayer match. More...
 
Action< IMatchPresenceEventReceivedMatchPresence
 Received a presence change for joins and leaves of users in a multiplayer match. More...
 
Action< IApiNotificationReceivedNotification
 Received a notification for the current user. More...
 
Action< IPartyReceivedParty
 Received a party event. This will occur when the current user's invitation request is accepted by the party leader of a closed party. More...
 
Action< IPartyCloseReceivedPartyClose
 Received a party close event. More...
 
Action< IPartyDataReceivedPartyData
 Received custom party data. More...
 
Action< IPartyJoinRequestReceivedPartyJoinRequest
 Received a request to join the party. More...
 
Action< IPartyLeaderReceivedPartyLeader
 Received a change in the party leader. More...
 
Action< IPartyMatchmakerTicketReceivedPartyMatchmakerTicket
 Received a new matchmaker ticket for the party. More...
 
Action< IPartyPresenceEventReceivedPartyPresence
 Received a new presence event in the party. More...
 
Action< IStatusPresenceEventReceivedStatusPresence
 Received a presence change for when a user updated their online status. More...
 
Action< IStreamPresenceEventReceivedStreamPresence
 Received a presence change for joins and leaves on a realtime stream. More...
 
Action< IStreamStateReceivedStreamState
 Received a message from a realtime stream. More...
 

Detailed Description

A socket which implements the Nakama realtime API.

Constructor & Destructor Documentation

◆ Socket() [1/3]

Nakama.Socket.Socket ( )
inline

A new socket with default options.

◆ Socket() [2/3]

Nakama.Socket.Socket ( ISocketAdapter  adapter)
inline

A new socket with an adapter.

Parameters
adapterThe adapter for use with the socket.

◆ Socket() [3/3]

Nakama.Socket.Socket ( string  scheme,
string  host,
int  port,
ISocketAdapter  adapter 
)
inline

A new socket with server connection and adapter options.

Parameters
schemeThe protocol scheme. Must be "ws" or "wss".
hostThe host address of the server.
portThe port number of the server.
adapterThe adapter for use with the socket.

Member Function Documentation

◆ AcceptPartyMemberAsync()

Task Nakama.Socket.AcceptPartyMemberAsync ( string  partyId,
IUserPresence  presence 
)
inline

Accept a party member's request to join the party.

Implements Nakama.ISocket.

◆ AddMatchmakerAsync()

async Task< IMatchmakerTicket > Nakama.Socket.AddMatchmakerAsync ( string  query = "*",
int  minCount = 2,
int  maxCount = 8,
Dictionary< string, string >  stringProperties = null,
Dictionary< string, double >  numericProperties = null 
)
inline

Join the matchmaker pool and search for opponents on the server.

Implements Nakama.ISocket.

◆ AddMatchmakerPartyAsync()

async Task< IPartyMatchmakerTicket > Nakama.Socket.AddMatchmakerPartyAsync ( string  partyId,
string  query,
int  minCount,
int  maxCount,
Dictionary< string, string >  stringProperties = null,
Dictionary< string, double >  numericProperties = null 
)
inline

Begin matchmaking as a party.

Implements Nakama.ISocket.

◆ CloseAsync()

Task Nakama.Socket.CloseAsync ( )
inline

Close the socket connection to the server.

Implements Nakama.ISocket.

◆ ClosePartyAsync()

Task Nakama.Socket.ClosePartyAsync ( string  partyId)
inline

End a party, kicking all party members and closing it.

Implements Nakama.ISocket.

◆ ConnectAsync()

Task Nakama.Socket.ConnectAsync ( ISession  session,
bool  appearOnline = false,
int  connectTimeoutSec = DefaultConnectTimeout,
string  langTag = "en" 
)
inline

Connect to the server.

Implements Nakama.ISocket.

◆ CreateMatchAsync()

async Task< IMatch > Nakama.Socket.CreateMatchAsync ( )
inline

Create a multiplayer match on the server.

Implements Nakama.ISocket.

◆ CreatePartyAsync()

async Task< IParty > Nakama.Socket.CreatePartyAsync ( bool  open,
int  maxSize 
)
inline

Create a party.

Implements Nakama.ISocket.

◆ Dispose()

void Nakama.Socket.Dispose ( )
inline

Dispose will destroy the active socket and clean up all associated resources.

NOTE: This method will block to close the socket if it is open when called. Use CloseAsync instead wherever possible.

◆ FollowUsersAsync() [1/2]

Task< IStatus > Nakama.Socket.FollowUsersAsync ( IEnumerable< IApiUser users)

Subscribe to one or more users for their status updates.

Implements Nakama.ISocket.

◆ FollowUsersAsync() [2/2]

async Task< IStatus > Nakama.Socket.FollowUsersAsync ( IEnumerable< string >  userIDs,
IEnumerable< string >  usernames = null 
)
inline

Subscribe to one or more users for their status updates.

Implements Nakama.ISocket.

◆ From() [1/2]

static ISocket Nakama.Socket.From ( IClient  client)
static

Build a socket from a client object.

Parameters
clientA client object.
Returns
A new socket with the connection settings from the client.

◆ From() [2/2]

static ISocket Nakama.Socket.From ( IClient  client,
ISocketAdapter  adapter 
)
inlinestatic

Build a socket from a client object and socket adapter.

Parameters
clientA client object.
adapterThe socket adapter to use with the connection.
Returns
A new socket with connection settings from the client.

◆ JoinChatAsync()

async Task< IChannel > Nakama.Socket.JoinChatAsync ( string  target,
ChannelType  type,
bool  persistence = false,
bool  hidden = false 
)
inline

Join a chat channel on the server.

Implements Nakama.ISocket.

◆ JoinMatchAsync() [1/2]

async Task< IMatch > Nakama.Socket.JoinMatchAsync ( IMatchmakerMatched  matched)
inline

Join a multiplayer match with the matchmaker matched object.

Implements Nakama.ISocket.

◆ JoinMatchAsync() [2/2]

async Task< IMatch > Nakama.Socket.JoinMatchAsync ( string  matchId,
IDictionary< string, string >  metadata = null 
)
inline

Join a multiplayer match by ID.

Implements Nakama.ISocket.

◆ JoinPartyAsync()

Task Nakama.Socket.JoinPartyAsync ( string  partyId)
inline

Join a party.

Implements Nakama.ISocket.

◆ LeaveChatAsync() [1/2]

Task Nakama.Socket.LeaveChatAsync ( IChannel  channel)

Leave a chat channel on the server.

Implements Nakama.ISocket.

◆ LeaveChatAsync() [2/2]

Task Nakama.Socket.LeaveChatAsync ( string  channelId)
inline

Leave a chat channel on the server.

Implements Nakama.ISocket.

◆ LeaveMatchAsync() [1/2]

Task Nakama.Socket.LeaveMatchAsync ( IMatch  match)

Leave a multiplayer match on the server.

Implements Nakama.ISocket.

◆ LeaveMatchAsync() [2/2]

Task Nakama.Socket.LeaveMatchAsync ( string  matchId)
inline

Leave a multiplayer match on the server.

Implements Nakama.ISocket.

◆ LeavePartyAsync()

Task Nakama.Socket.LeavePartyAsync ( string  partyId)
inline

Leave the party.

Implements Nakama.ISocket.

◆ ListPartyJoinRequestsAsync()

async Task< IPartyJoinRequest > Nakama.Socket.ListPartyJoinRequestsAsync ( string  partyId)
inline

Request a list of pending join requests for a party.

Implements Nakama.ISocket.

◆ PromotePartyMemberAsync()

Task Nakama.Socket.PromotePartyMemberAsync ( string  partyId,
IUserPresence  partyMember 
)
inline

Promote a new party leader.

Implements Nakama.ISocket.

◆ RemoveChatMessageAsync() [1/2]

Task< IChannelMessageAck > Nakama.Socket.RemoveChatMessageAsync ( IChannel  channel,
string  messageId 
)

Remove a chat message from a chat channel on the server.

Implements Nakama.ISocket.

◆ RemoveChatMessageAsync() [2/2]

async Task< IChannelMessageAck > Nakama.Socket.RemoveChatMessageAsync ( string  channelId,
string  messageId 
)
inline

Remove a chat message from a chat channel on the server.

Implements Nakama.ISocket.

◆ RemoveMatchmakerAsync() [1/2]

Task Nakama.Socket.RemoveMatchmakerAsync ( IMatchmakerTicket  ticket)

Leave the matchmaker pool with the ticket.

Implements Nakama.ISocket.

◆ RemoveMatchmakerAsync() [2/2]

Task Nakama.Socket.RemoveMatchmakerAsync ( string  ticket)
inline

Leave the matchmaker pool with the ticket contents.

Implements Nakama.ISocket.

◆ RemoveMatchmakerPartyAsync()

Task Nakama.Socket.RemoveMatchmakerPartyAsync ( string  partyId,
string  ticket 
)
inline

<inheritdoc="RemoveMatchmakerPartyAsync"/>

Implements Nakama.ISocket.

◆ RemovePartyMemberAsync()

Task Nakama.Socket.RemovePartyMemberAsync ( string  partyId,
IUserPresence  presence 
)
inline

<inheritdoc="RemovePartyMemberAsync"/>

Implements Nakama.ISocket.

◆ RpcAsync() [1/2]

async Task< IApiRpc > Nakama.Socket.RpcAsync ( string  funcId,
ArraySegment< byte >  payload 
)
inline

Execute an RPC function to the server.

Implements Nakama.ISocket.

◆ RpcAsync() [2/2]

async Task< IApiRpc > Nakama.Socket.RpcAsync ( string  funcId,
string  payload = null 
)
inline

Execute an RPC function to the server.

Implements Nakama.ISocket.

◆ SendMatchStateAsync() [1/3]

Task Nakama.Socket.SendMatchStateAsync ( string  matchId,
long  opCode,
ArraySegment< byte >  state,
IEnumerable< IUserPresence presences = null 
)
inline

Send input to a multiplayer match on the server.

Implements Nakama.ISocket.

◆ SendMatchStateAsync() [2/3]

Task Nakama.Socket.SendMatchStateAsync ( string  matchId,
long  opCode,
byte[]  state,
IEnumerable< IUserPresence presences = null 
)
inline

Send input to a multiplayer match on the server.

Implements Nakama.ISocket.

◆ SendMatchStateAsync() [3/3]

Task Nakama.Socket.SendMatchStateAsync ( string  matchId,
long  opCode,
string  state,
IEnumerable< IUserPresence presences = null 
)

Send input to a multiplayer match on the server.

Implements Nakama.ISocket.

◆ SendPartyDataAsync() [1/3]

Task Nakama.Socket.SendPartyDataAsync ( string  partyId,
long  opCode,
ArraySegment< byte >  data 
)
inline

Send data to a party.

Implements Nakama.ISocket.

◆ SendPartyDataAsync() [2/3]

Task Nakama.Socket.SendPartyDataAsync ( string  partyId,
long  opCode,
byte[]  data 
)
inline

Send data to a party.

Implements Nakama.ISocket.

◆ SendPartyDataAsync() [3/3]

Task Nakama.Socket.SendPartyDataAsync ( string  partyId,
long  opCode,
string  data 
)

Send data to a party.

Implements Nakama.ISocket.

◆ ToString()

override string Nakama.Socket.ToString ( )
inline

◆ UnfollowUsersAsync() [1/2]

Task Nakama.Socket.UnfollowUsersAsync ( IEnumerable< IApiUser users)

Unfollow one or more users from their status updates.

Implements Nakama.ISocket.

◆ UnfollowUsersAsync() [2/2]

Task Nakama.Socket.UnfollowUsersAsync ( IEnumerable< string >  userIDs)
inline

Unfollow one or more users from their status updates.

Implements Nakama.ISocket.

◆ UpdateChatMessageAsync() [1/2]

Task< IChannelMessageAck > Nakama.Socket.UpdateChatMessageAsync ( IChannel  channel,
string  messageId,
string  content 
)

Update a chat message on a chat channel in the server.

Implements Nakama.ISocket.

◆ UpdateChatMessageAsync() [2/2]

async Task< IChannelMessageAck > Nakama.Socket.UpdateChatMessageAsync ( string  channelId,
string  messageId,
string  content 
)
inline

Update a chat message on a chat channel in the server.

Implements Nakama.ISocket.

◆ UpdateStatusAsync()

Task Nakama.Socket.UpdateStatusAsync ( string  status)
inline

Update the status for the current user online.

Implements Nakama.ISocket.

◆ WriteChatMessageAsync() [1/2]

Task< IChannelMessageAck > Nakama.Socket.WriteChatMessageAsync ( IChannel  channel,
string  content 
)

Send a chat message to a chat channel on the server.

Implements Nakama.ISocket.

◆ WriteChatMessageAsync() [2/2]

async Task< IChannelMessageAck > Nakama.Socket.WriteChatMessageAsync ( string  channelId,
string  content 
)
inline

Send a chat message to a chat channel on the server.

Implements Nakama.ISocket.

Member Data Documentation

◆ DefaultConnectTimeout

const int Nakama.Socket.DefaultConnectTimeout = 30
static

The default timeout for when the socket connects.

Property Documentation

◆ IsConnected

bool Nakama.Socket.IsConnected
get

◆ IsConnecting

bool Nakama.Socket.IsConnecting
get

◆ Logger

ILogger Nakama.Socket.Logger
getset

The logger to use with the socket.

Event Documentation

◆ Closed

Action Nakama.Socket.Closed

◆ Connected

Action Nakama.Socket.Connected

◆ ReceivedChannelMessage

Action<IApiChannelMessage> Nakama.Socket.ReceivedChannelMessage

◆ ReceivedChannelPresence

Action<IChannelPresenceEvent> Nakama.Socket.ReceivedChannelPresence

◆ ReceivedError

Action<Exception> Nakama.Socket.ReceivedError

◆ ReceivedMatchmakerMatched

Action<IMatchmakerMatched> Nakama.Socket.ReceivedMatchmakerMatched

◆ ReceivedMatchPresence

Action<IMatchPresenceEvent> Nakama.Socket.ReceivedMatchPresence

◆ ReceivedMatchState

Action<IMatchState> Nakama.Socket.ReceivedMatchState

◆ ReceivedNotification

Action<IApiNotification> Nakama.Socket.ReceivedNotification

◆ ReceivedParty

Action<IParty> Nakama.Socket.ReceivedParty

◆ ReceivedPartyClose

Action<IPartyClose> Nakama.Socket.ReceivedPartyClose

◆ ReceivedPartyData

Action<IPartyData> Nakama.Socket.ReceivedPartyData

◆ ReceivedPartyJoinRequest

Action<IPartyJoinRequest> Nakama.Socket.ReceivedPartyJoinRequest

◆ ReceivedPartyLeader

Action<IPartyLeader> Nakama.Socket.ReceivedPartyLeader

◆ ReceivedPartyMatchmakerTicket

Action<IPartyMatchmakerTicket> Nakama.Socket.ReceivedPartyMatchmakerTicket

◆ ReceivedPartyPresence

Action<IPartyPresenceEvent> Nakama.Socket.ReceivedPartyPresence

◆ ReceivedStatusPresence

Action<IStatusPresenceEvent> Nakama.Socket.ReceivedStatusPresence

◆ ReceivedStreamPresence

Action<IStreamPresenceEvent> Nakama.Socket.ReceivedStreamPresence

◆ ReceivedStreamState

Action<IStreamState> Nakama.Socket.ReceivedStreamState


The documentation for this class was generated from the following file: