Skip to main content

PubSubMessage

Represents a message in a PubSub context.

Properties

id
stringrequired

The id of this message.

channel
stringrequired

The channel in which this message was sent.

content
anyrequired

The content of this message.

publishedAt
Daterequired

The date and time at which this message was published.

meta
any

Any metadata associated to this message.

Example

Listening for PubSub messages and accessing PubSubMessage properties:

import { SignalWire } from "@signalwire/realtime-api";

const client = await SignalWire({ project: "your-project-id", token: "your-api-token" });

await client.pubSub.listen({
channels: ["my-channel"],
onMessageReceived: (message) => {
console.log("Message ID:", message.id);
console.log("Channel:", message.channel);
console.log("Content:", message.content);
console.log("Published at:", message.publishedAt);
console.log("Metadata:", message.meta);
}
});