TsgcWebSocketServer › 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. 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. By default NotifyEvents is neAsynchronous and the handler runs synchronized with the main thread, which makes it safe to update UI controls; for high-throughput servers set NotifyEvents to neNoSync to dispatch in the connection thread and implement your own synchronization. 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;