Creates an instance of a WebPubSubEventHandler for handling incoming CloudEvents messages.
Example usage:
import express from "express";
import { WebPubSubEventHandler } from "@azure/web-pubsub-express";
const endpoint = "https://xxxx.webpubsubdev.azure.com"
const handler = new WebPubSubEventHandler('chat', [ endpoint ] {
handleConnect: (req, res) => {
console.log(JSON.stringify(req));
return {};
},
onConnected: req => {
console.log(JSON.stringify(req));
},
handleUserEvent: (req, res) => {
console.log(JSON.stringify(req));
res.success("Hey " + req.data, req.dataType);
};
},
});
The name of the hub to listen to
The allowed endpoints for the incoming CloudEvents request
Options to configure the event handler
The path this CloudEvents handler listens to
Get the middleware to process the CloudEvents requests
Generated using TypeDoc
The handler to handle incoming CloudEvents messages