Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebPubSubEventHandler

Package version

The handler to handle incoming CloudEvents messages

Hierarchy

  • WebPubSubEventHandler

Index

Constructors

Properties

Methods

Constructors

constructor

  • 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);
       };
     },
    });

    Parameters

    • hub: string

      The name of the hub to listen to

    • allowedEndpoints: string[]

      The allowed endpoints for the incoming CloudEvents request

    • Optional options: WebPubSubEventHandlerOptions

      Options to configure the event handler

    Returns WebPubSubEventHandler

Properties

path

path: string

The path this CloudEvents handler listens to

Methods

getMiddleware

  • getMiddleware(): express.RequestHandler

Generated using TypeDoc