TsgcWSPServer_WebRTCEvents › OnDisconnect

OnDisconnect Event

Fires on the server when a signalling peer closes its transport or the server drops it.

Syntax

property OnDisconnect: TsgcWSDisconnectEvent;
// TsgcWSDisconnectEvent = procedure(Connection: TsgcWSConnection; Code: Integer) of object

Default Value

Remarks

Code carries the WebSocket close code (1000 normal, 1001 going away, 1006 abnormal) or the TCP error when a lower-level break occurs. Before the handler runs, the signalling layer updates its subscription table: when WebRTC.CloseSessionOnHangup is True every subscriber of the peer's last channel is removed, otherwise the subscriber counter is just decremented so the remaining peer can wait for a reconnect. The actual WebRTC media connection between browsers is unaffected — this event only concerns the signalling socket.

Example


procedure TForm1.WebRTCServerDisconnect(Connection: TsgcWSConnection;
  Code: Integer);
begin
  Memo1.Lines.Add(Format('peer %s disconnected (code %d)',
    [Connection.Guid, Code]));
end;

Back to Events