Skip to main content

PubSub

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

info

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.

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

const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })

const pubSubClient = client.pubSub;

await pubSubClient.listen({
channels: ["welcome"],
onMessageReceived: (message) => {
console.log("Received message:", message);
}
});

Classes