TsgcWSPServer_WebRTC › Events › OnConnect
Fires on the server once a peer finishes the WebSocket handshake and attaches to the WebRTC signalling subprotocol.
property OnConnect: TsgcWSConnectEvent;
// TsgcWSConnectEvent = procedure(Connection: TsgcWSConnection) of object
—
Raised once per peer immediately after the underlying TsgcWebSocketServer accepts the upgrade and routes the connection to this subprotocol handler. If WebRTC.IceServers is populated, the component has already pushed an sgc@iceservers frame so the browser can feed them to RTCPeerConnection before any subscription happens. Use the handler to log the join, bind per-peer state to Connection or inspect authentication headers extracted by the transport.
procedure TForm1.WebRTCServerConnect(Connection: TsgcWSConnection);
begin
Memo1.Lines.Add(Format('peer %s connected from %s',
[Connection.Guid, Connection.PeerIP]));
end;