TsgcWSPServer_Dataset › Methods › Broadcast
Broadcasts a text or stream payload to all connected clients, optionally filtered by channel.
procedure Broadcast(aMessage: string; aChannel: string = ''; Exclude: String = ''; Include: String = '');
| Name | Type | Description |
|---|---|---|
aMessage | string | Text payload wrapped in the sgc envelope and delivered to recipients through OnMessage. |
aChannel | string | Optional channel filter. When supplied, only clients subscribed to that channel receive the payload; leave empty to reach every connection. |
Exclude | String | Semicolon-separated list of connection Guids that must not receive the broadcast. |
Include | String | Semicolon-separated list of connection Guids that the broadcast is restricted to, overriding the channel filter. |
Text overload. Sends a method=message envelope to the selected recipients, independent from the internal dataset update channel. Use it for side-band notifications (status, presence, custom signalling) that should reach peers without going through the dataset sync path.
oProtocol.Broadcast('hello everyone');
oProtocol.Broadcast('channel update', 'news');
procedure Broadcast(aStream: TStream; aChannel: string = ''; Exclude: String = ''; Include: String = ''; aSize: Integer = 0; aStreaming: TwsStreaming = stmNone);
| Name | Type | Description |
|---|---|---|
aStream | TStream | Binary payload sent as-is on the WebSocket; recipients receive it through OnBinary. |
aChannel | string | Optional channel filter. When supplied, only clients subscribed to that channel receive the frame. |
Exclude | String | Semicolon-separated list of connection Guids that must not receive the frame. |
Include | String | Semicolon-separated list of connection Guids that the frame is restricted to. |
aSize | Integer | Chunk size in bytes when the payload is fragmented; pass 0 to send the stream as a single frame. |
aStreaming | TwsStreaming | Streaming strategy (stmNone, stmFragmented, stmCustom) used to chop the stream into frames. |
Binary overload. Dispatches the stream directly to selected recipients without wrapping it in the sgc JSON envelope, so clients see a raw binary frame. Useful to push attachments, images or protobuf payloads alongside the dataset sync.
oStream := TFileStream.Create('image.png', fmOpenRead);
try
oProtocol.Broadcast(oStream, 'news');
finally
oStream.Free;
end;