Direct Message

All user clients that are connected to the Diarkis cluster may send and receive direct messages by targeting recipient's user ID.

Direct Message does not require the user clients to be joining a room, groups, or field.

NOTE

Message delivery may take some time (a few seconds) when sending a message to a remote user client for the first time as the server must look for the recipient user.

How To Send A Message And Receiving Using UDP

DirectMessage dm = new DirectMessage();

// Pass Diarkis UDP client class instance that has established connection
dm.SetupAsUdp(udp);

dm.OnMessage += (string uid, byte[] message) =>
{
// Message from the remote user client
};

dm.OnDisconnect += (string uid, byte[] message) =>
{
// This event is raised when the remote user client executes Disconnect
};

// Send a message (plain UDP)
dm.Send(remoteUserID, Encoding.UTF8.GetBytes("Hello"));

// Send a message (RUDP)
dm.RSend(remoteUserID, Encoding.UTF8.GetBytes("Hello"));

How To Send A Message And Receiving Using TCP

DirectMessage dm = new DirectMessage();

// Pass Diarkis TCP client class instance that has established connection
dm.SetupAsTcp(tcp);

dm.OnMessage += (string uid, byte[] message) =>
{
// Message from the remote user client
};

dm.OnDisconnect += (string uid, byte[] message) =>
{
// This event is raised when the remote user client executes Disconnect
};

// Send a message
dm.Send(remoteUserID, Encoding.UTF8.GetBytes("Hello"));