Skip to content

Message

Mathias Cloet edited this page Feb 6, 2020 · 1 revision

A standard message that can be send from client to server or from server to client.

Client to server

public void SendMessage(string message, bool compress = false, bool encrypt = false, bool close = false);
public async Task SendMessageAsync(string message, bool compress = false, bool encrypt = false, bool close = false);

When one of the above methods is used to send a message to the server, the server will invoke the MessageReceived event.

Server to client

The messaging from server to client is almost identical, the only difference is the id parameter. The id should correspond to an id of a connected client. A list of connected clients can be retrieved by using 'GetConnectedClients()'

public void SendMessage(int id, string message, bool compress = false, bool encrypt = false, bool close = false);
public async Task SendMessageAsync(int id, string message, bool compress = false, bool encrypt = false,bool close = false);

When one of the above methods is used to send a message to a client, the client will invoke the MessageReceived event.

/// <summary>
/// Returns all currently connected clients
/// </summary>
/// <returns></returns>
public IDictionary<int, IClientInfo> GetConnectedClients()
Clone this wiki locally