TsgcWSPServer_WebRTC › Methods › WriteData
Sends a text payload to a single connected peer identified by its connection GUID.
function WriteData(aGuid, aMessage: string): Boolean;
| Name | Type | Description |
|---|---|---|
aGuid | string | GUID of the target connection (the value of TsgcWSConnection.Guid captured in OnConnect or returned to the peer at handshake time). |
aMessage | string | Text payload to deliver; wrapped in the signalling envelope with an empty Method and Channel before being sent out. |
True if a live connection with that GUID was found and the frame was queued for delivery; False when no such peer is connected. (Boolean)
Low-level unicast primitive: targets a specific peer by GUID regardless of channel subscriptions, which makes it the right call for acknowledgments, server-initiated invitations or direct administrative messages. The payload is wrapped in a signalling envelope so the JavaScript shim can deliver it to the browser's application callback; it does not itself carry an SDP offer/answer or ICE candidate — those relays are triggered automatically by the peer-to-peer sgc@webrtc flow when clients negotiate.
// greet the peer that just joined with a welcome payload
procedure TForm1.WebRTCConnect(Connection: TsgcWSConnection);
begin
WebRTCSrv.WriteData(Connection.Guid, '{"type":"welcome"}');
end;