TsgcWebSocketServer_HTTPAPI › Events › OnMessage
Fires every time a client sends a text message and it is received by the server.
property OnMessage: TsgcWSMessageEvent;
// TsgcWSMessageEvent = procedure(Connection: TsgcWSConnection; const Text: string) of object
—
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.
procedure OnMessage(Connection: TsgcWSConnection; const Text: string);
begin
ShowMessage('Message Received from Client: ' + Text);
end;