publish( )


Publishes a message to a channel or channel resource.

The publish() function publishes a message to the specified channel or channel resource.

When site visitors subscribe to a channel, they do not receive messages published to a resource on that same channel. Similarly, when site visitors subscribe to a channel resource, they do not receive messages published to that same channel without a specified resource.

To publish a message to specific users only, specify the users by ID in the PublishOptions object sent to the options parameter.

To include the ID of the user who triggered the publish in the published message, set the includePublisher property of the PublishOptions object to true.

Method Declaration
Copy
Method Parameters
channelChannelRequired

The channel, and optionally the resource, to publish to.


payloadanyRequired

Message payload. Max: 10kb


optionsPublishOptions

Options to use when publishing.

Was this helpful?
Yes
No