TsgcWSPServer_WAMP › Methods › Event
Publishes an EVENT message (type 8) to every client currently subscribed to the given topic URI.
procedure Event(const aTopicURI: String; const aEvent: String = '');
| Name | Type | Description |
|---|---|---|
aTopicURI | const String | URI (or CURIE) of the PubSub channel whose subscribers will receive the event, for example http://example.com/simple. |
aEvent | const String | Event payload delivered to each subscriber. Any serialized value is allowed (plain text, number, JSON object, JSON array, etc.). |
This is the server-side broadcast entry point for WAMP v1 PubSub. The broker walks the list of connections subscribed to aTopicURI and writes a WAMP EVENT frame [8, TopicURI, Event] to each of them; connections that are not subscribed to the topic are skipped. If no client is currently subscribed, the event is simply discarded. The topic URI used here must match the one clients passed to Subscribe (or be covered by a known prefix registered through OnPrefix). Use this method to push server-originated notifications; client-originated publishes arrive through the normal PUBLISH pipeline and are re-dispatched by the broker automatically.
procedure TForm1.BroadcastTemperature(aValue: Double);
begin
sgcWSPServer_WAMP1.Event('http://example.com/sensors/temperature',
Format('{"value":%.2f}', [aValue]));
end;