TsgcTCPClient › Gebeurtenissen › OnMessage
Wordt gegenereerd wanneer onbewerkte bytes ontvangen van de TCP-server als tekst kunnen worden gepresenteerd.
property OnMessage: TsgcWSMessageEvent;
// TsgcWSMessageEvent = procedure(Connection: TsgcWSConnection; const Text: string) of object
—
Unlike the WebSocket client, TsgcTCPClient does not negotiate a handshake and does not receive framed messages, so OnMessage delivers the raw bytes that arrived on the TCP socket converted to a tekenreeks. When TCPEndOfFrameScanBuffer is eofScanNone every read is surfaced as it arrives; when it is eofScanLatestBytes or eofScanAllBytes de buffer is split on the TCPEndOfFrame delimiter and one event is raised per logical frame. The Tekst parameter carries the UTF-8 decoded payload; use OnBinary instead if de server sends non-textual data. Standaard NotifyEvents is neAsynchronous, so de handler runs in the context of the main thread and it is safe to update UI controls rechtstreeks; switch to neNoSync if de client receives a high volume of data and you prefer to handle synchronization uzelf.
procedure OnMessage(Connection: TsgcWSConnection; const Text: string);
begin
ShowMessage('Received from TCP server: ' + Text);
end;