TsgcRTCPeerConnectionEvents › OnRTCMessage

OnRTCMessage Event

Fired when data is received from the remote peer through the data channel.

Syntax

property OnRTCMessage: TsgcRTCMessageEvent;
// TsgcRTCMessageEvent = procedure(Sender: TObject; const aBytes: TBytes) of object

Default Value

Remarks

Raised whenever the component receives application data from the remote peer over the negotiated path. When DTLS is enabled the bytes have already been decrypted; when DTLS is disabled the raw UDP payload is delivered unchanged. aBytes holds the exact frame that was written by the peer — convert it to a string with UTF8ToString when plain text was sent, or process it as binary.

Example

procedure TForm1.oRTCMessage(Sender: TObject; const aBytes: TBytes);
var
  vText: string;
begin
  vText := TEncoding.UTF8.GetString(aBytes);
  Log('<< ' + vText);
end;

Back to Events