TsgcWSPServer_WAMPMethods › Event

Event Method

Publishes an EVENT message (type 8) to every client currently subscribed to the given topic URI.

Syntax

procedure Event(const aTopicURI: String; const aEvent: String = '');

Parameters

NameTypeDescription
aTopicURIconst StringURI (or CURIE) of the PubSub channel whose subscribers will receive the event, for example http://example.com/simple.
aEventconst StringEvent payload delivered to each subscriber. Any serialized value is allowed (plain text, number, JSON object, JSON array, etc.).

Remarks

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.

Example

procedure TForm1.BroadcastTemperature(aValue: Double);
begin
  sgcWSPServer_WAMP1.Event('http://example.com/sensors/temperature',
    Format('{"value":%.2f}', [aValue]));
end;

Back to Methods