TsgcWSPServer_WAMP › Events › OnSubscription
Fires after a client subscription has been accepted and the broker has registered the client against the topic.
property OnSubscription: TsgcWSSubscriptionEvent;
// TsgcWSSubscriptionEvent = procedure(Connection: TsgcWSConnection; const Subscription: String) of object
—
Runs immediately after OnBeforeSubscription returned Accept := True and the internal broker table has been updated. Subscription is the canonical topic URI. This is the right place to publish a welcome event to the newly-subscribed client (via the Event method) or to emit audit/metric records that a client has joined a topic. The handler is informational only — there is no way to cancel the subscription from here, use OnBeforeSubscription for access control.
procedure TForm1.WAMPServerSubscription(Connection: TsgcWSConnection;
const Subscription: String);
begin
Memo1.Lines.Add(Format('[%s] joined %s', [Connection.Guid, Subscription]));
// push a current snapshot to the new subscriber only
WSPServerWAMP1.Event(Subscription, '{"snapshot":true}');
end;