TsgcWSPServer_sgcEvents › OnRawMessage

OnRawMessage Event

Fires before a text message is decoded, allowing the handler to consume it.

Syntax

property OnRawMessage: TsgcWSRawMessageEvent;
// TsgcWSRawMessageEvent = procedure(Connection: TsgcWSConnection; const Text: string; var Handled: Boolean) of object

Default Value

Remarks

Raised for every text frame before the subprotocol parses the sgc envelope. Text is the raw string as delivered on the wire. Set Handled to True to take over the message; the server then skips envelope parsing, RPC dispatch, PubSub and OnMessage/OnNotification/OnRPC for this frame. Leave it False to keep the default behaviour.

Example

procedure TForm1.oProtocolRawMessage(Connection: TsgcWSConnection;
  const Text: string; var Handled: Boolean);
begin
  if Text.StartsWith('PING') then
  begin
    oProtocol.WriteData(Connection.Guid, 'PONG');
    Handled := True;
  end;
end;

Back to Events