RTCPeerConnection | Data

Once the connection is successful, you can use the method WriteData to send some message to the other peer. The connection will make use of DTLS over UDP, and if possible the connection will be P2P (or using a relayed address when P2P is not possible).

 

Send Data

Use the method WriteData to send any data to the other peer. You can send a string or an array of bytes.

 


oRTCPeerConnection := TsgcRTCPeerConnection.Create(nil);
...
oRTCPeerConnection.WriteData('Hello from sgcWebSockets!!!');

 

Receive Data

Every time the TsgcRTCPeerConnection receives any data from the other peer, the event OnRTCMessage will be called.

 


procedure OnRTCMessage(Sender: TObject; const aBytes: TBytes);
begin
  ShowMessage(TEncoding.UTF8.GetString(aBytes));
end;