TsgcWebSocketClientEvents › OnMessage

OnMessage Event

Fires every time the server sends a text message to the client.

Syntax

public event TsgcWSMessageEventHandler OnMessage;
// delegate void TsgcWSMessageEventHandler(TsgcWSConnection Connection, string Text)

Default Value

Remarks

OnMessage is raised once a complete text frame has been received from the server. The Text parameter carries the decoded UTF-8 string; the Connection parameter identifies the session on which the message arrived. By default NotifyEvents is neAsynchronous, so the handler runs in the context of the main thread and it is safe to update UI controls directly; switch to neNoSync if the client receives a high volume of messages and you prefer to handle synchronization yourself. If Options.FragmentedMessages is frgOnlyFragmented this event is not raised and the payload is delivered through OnFragmented instead.

Example


void OnMessage(TsgcWSConnection Connection, string Text)
{
  MessageBox.Show("Message Received from Server: " + Text);
}

Back to Events