PubSub

View as Markdown

Access the PubSub API Consumer. You can instantiate a PubSub.Client to subscribe to PubSub events.

Refer to PubSub Events for the full list of events that a PubSub.Client can subscribe to.

Example

The following example logs the messages sent to the “welcome” channel.

1import { SignalWire} from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
4
5const pubSubClient = client.pubSub;
6
7await pubSubClient.listen({
8 channels: ["welcome"],
9 onMessageReceived: (message) => {
10 console.log("Received message:", message);
11 }
12});

Classes