TsgcWSPServer_WebRTC › Events › OnBeforeSubscription
Fires when a peer asks to join a signalling channel, giving the server the chance to accept or reject the subscription.
property OnBeforeSubscription: TsgcWSBeforeSubscriptionEvent;
// TsgcWSBeforeSubscriptionEvent = procedure(Connection: TsgcWSConnection; const Subscription: String; var Accept: Boolean) of object
—
Subscription is the channel (or room) name the peer sent with its sgc@subscribe envelope — the same string the second peer must use for SDP/ICE relay to work. Accept is True by default; set it to False to drop the SUBSCRIBE silently so the peer is never added to the channel, which is the typical access-control hook (ACL, invite token, capacity cap). When Accept stays True the component adds the connection to the subscriber table, bumps the subscriber counter returned to the client and fires OnSubscription.
procedure TForm1.WebRTCServerBeforeSubscription(Connection: TsgcWSConnection;
const Subscription: String; var Accept: Boolean);
begin
// cap rooms at two peers so sessions are strictly one-to-one
Accept := WebRTCSrv.WebRTCSubscriptions.IndexOfName(
WebRTCSrv.Guid + '_' + Subscription) = -1;
Memo1.Lines.Add(Format('[%s] SUBSCRIBE %s -> %s',
[Connection.Guid, Subscription, BoolToStr(Accept, True)]));
end;