TsgcWSPServer_sgcMethods › Publish

Publish Method

Publishes a message to every client subscribed to a channel.

Overloads

Overload 1

Syntax

procedure Publish(const aMessage, aChannel: String; const aExclude: String = ''; const aInclude: String = ''; const aQueue: TwsQueue = queueLevel0);

Parameters

NameTypeDescription
aMessageconst StringPayload to publish; delivered to subscribers through their OnEvent handler.
aChannelconst StringChannel the message is published on; wildcards such as news* fan out to every matching channel with active subscribers.
aExcludeconst StringSemicolon-separated list of connection Guids to skip when fanning out.
aIncludeconst StringSemicolon-separated list of connection Guids the publication is restricted to.
aQueueconst TwsQueueRetention policy: queueLevel0 (no retention), queueLevel1 (keep last message per channel), or queueLevel2 (queue every message) so subscribers that connect later receive them.

Remarks

Full overload. Expands wildcard channels against current subscriptions, writes a retained copy into the server-side queue when aQueue is queueLevel1 or queueLevel2, and then broadcasts the payload to all matching subscribers honouring the Exclude/Include filters.

Example

oProtocol.Publish('breaking news', 'news');
oProtocol.Publish('sticky banner', 'news', '', '', queueLevel1);

Overload 2

Syntax

procedure Publish(const aMessage, aChannel: String; const aQueue: TwsQueue);

Parameters

NameTypeDescription
aMessageconst StringPayload to publish; delivered to subscribers through OnEvent.
aChannelconst StringChannel to publish on; wildcards are supported.
aQueueconst TwsQueueRetention policy (queueLevel0, queueLevel1, queueLevel2) for late subscribers.

Remarks

Convenience overload that delegates to the full overload with empty Exclude and Include filters. Use this when you only need to select a retention level and want every matching subscriber to receive the message.

Example

oProtocol.Publish('tick', 'prices', queueLevel1);

Back to Methods