TsgcWebSocketServer_HTTPAPI › Events › OnMessage
Fires every time a client sends a text message and it is received by the server.
public event TsgcWSMessageEventHandler OnMessage;
// delegate void TsgcWSMessageEventHandler(TsgcWSConnection Connection, string Text)
—
OnMessage is raised once a complete text frame has been received from a client through the HTTP.SYS WebSocket pipeline. The Text parameter carries the decoded UTF-8 string and the Connection parameter identifies the sender session, so the handler can reply on the same connection or relay the message to other clients. The event runs in the context of the IOCP worker thread; if you need to update UI controls marshal the call to the main thread. If Options.FragmentedMessages is frgOnlyFragmented the event is not raised and the payload is delivered through OnFragmented instead.
void OnMessage(TsgcWSConnection Connection, string Text)
{
MessageBox.Show("Message Received from Client: " + Text);
}