TsgcWSPServer_WebRTCEvents › OnConnect

OnConnect 事件

当对端完成 WebSocket 握手并附加到 WebRTC 信令子协议时,在服务器端触发。

语法

property OnConnect: TsgcWSConnectEvent;
// TsgcWSConnectEvent = procedure(Connection: TsgcWSConnection) of object

默认值

备注

在底层 TsgcWebSocketServer 接受升级并将连接路由到此子协议处理程序后,每个对端触发一次。如果 WebRTC.IceServers 已填充,组件已推送一个 sgc@iceservers 帧,以便浏览器在任何订阅发生之前将其提供给 RTCPeerConnection。使用处理程序记录加入信息、将每对端状态绑定到 Connection,或检查由传输层提取的身份验证标头。

示例


procedure TForm1.WebRTCServerConnect(Connection: TsgcWSConnection);
begin
  Memo1.Lines.Add(Format('peer %s connected from %s',
    [Connection.Guid, Connection.PeerIP]));
end;

返回事件