From 446eed1f66330c4ced6c4bd5738d9e060a1ac14c Mon Sep 17 00:00:00 2001 From: "Liangying.Wei" Date: Wed, 3 Nov 2021 00:59:07 +0800 Subject: [PATCH] [Web Pubsub Express] Preparing for beta.4 release (#18417) --- .../web-pubsub-express/CHANGELOG.md | 24 ++++++++++++++++++- sdk/web-pubsub/web-pubsub-express/README.md | 4 ++-- .../samples/v1/typescript/src/server.ts | 6 ++--- sdk/web-pubsub/web-pubsub/CHANGELOG.md | 11 +++++++-- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/sdk/web-pubsub/web-pubsub-express/CHANGELOG.md b/sdk/web-pubsub/web-pubsub-express/CHANGELOG.md index 6d8608c15df2..2cab7daf9323 100644 --- a/sdk/web-pubsub/web-pubsub-express/CHANGELOG.md +++ b/sdk/web-pubsub/web-pubsub-express/CHANGELOG.md @@ -1,11 +1,33 @@ # Release History -## 1.0.0-beta.4 (Unreleased) +## 1.0.0-beta.4 (2021-11-01) ### Features Added ### Breaking Changes +- Move `allowedEndpoints` settings into `WebPubSubEventHandlerOptions`. If not set, the default behavior is allowing all the incoming endpoints. + + ```js + const handler = new WebPubSubEventHandler("chat", { + handleConnect(req, res) { + // You can set the state for the connection, it lasts throughout the lifetime of the connection + res.setState("calledTime", 1); + res.success(); + }, + handleUserEvent(req, res) { + var calledTime = req.context.states.calledTime++; + console.log(calledTime); + // You can also set the state here + res.setState("calledTime", calledTime); + res.success(); + }, + allowedEndpoints: ["https://xxx.webpubsub.azure.com"] + }); + ``` + +- Remove `dumpRequest` flag and leverage @azure/logger instead. + ### Bugs Fixed ### Other Changes diff --git a/sdk/web-pubsub/web-pubsub-express/README.md b/sdk/web-pubsub/web-pubsub-express/README.md index 3daa422adba6..9d131de10a4b 100644 --- a/sdk/web-pubsub/web-pubsub-express/README.md +++ b/sdk/web-pubsub/web-pubsub-express/README.md @@ -43,14 +43,14 @@ const express = require("express"); const { WebPubSubEventHandler } = require("@azure/web-pubsub-express"); const handler = new WebPubSubEventHandler( "chat", - ["https://.webpubsub.azure.com"], { handleConnect: (req, res) => { // auth the connection and set the userId of the connection res.success({ userId: "" }); - } + }, + allowedEndpoints: ["https://.webpubsub.azure.com"] } ); diff --git a/sdk/web-pubsub/web-pubsub-express/samples/v1/typescript/src/server.ts b/sdk/web-pubsub/web-pubsub-express/samples/v1/typescript/src/server.ts index a912d586b092..582c8db3f92b 100644 --- a/sdk/web-pubsub/web-pubsub-express/samples/v1/typescript/src/server.ts +++ b/sdk/web-pubsub/web-pubsub-express/samples/v1/typescript/src/server.ts @@ -8,8 +8,7 @@ import { WebPubSubEventHandler } from "@azure/web-pubsub-express"; import express from "express"; -const handler = new WebPubSubEventHandler("chat", ["https://xxx.webpubsub.azure.com"], { - dumpRequest: false, +const handler = new WebPubSubEventHandler("chat", { handleConnect(req, res) { console.log(req); res.success(); @@ -22,7 +21,8 @@ const handler = new WebPubSubEventHandler("chat", ["https://xxx.webpubsub.azure. handleUserEvent(req, res) { console.log(req); res.success("Hello", "text"); - } + }, + allowedEndpoints: ["https://xxx.webpubsub.azure.com"] }); const app = express(); diff --git a/sdk/web-pubsub/web-pubsub/CHANGELOG.md b/sdk/web-pubsub/web-pubsub/CHANGELOG.md index af98c72e00fb..991be3c2f497 100644 --- a/sdk/web-pubsub/web-pubsub/CHANGELOG.md +++ b/sdk/web-pubsub/web-pubsub/CHANGELOG.md @@ -1,15 +1,22 @@ # Release History -## 1.0.0-beta.4 (Unreleased) +## 1.0.0-beta.4 (2021-11-01) ### Features Added - Support for DefaultAzureCredential -- Added generateClientToken method to the `HubClient`. - Added support for reverse proxies, enabling usage of Web Pubsub with Azure API Management. +- Added method to close all connections in a hub `serviceClient.closeAllConnections`, +- Added method to close all connections in a group `groupClient.closeAllConnections` +- Added method to close all connections for a user `serviceClient.closeUserConnections`. ### Breaking Changes +- Renamed method `getAuthenticationToken` to `getClientAccessToken` +- Renamed method `hasUser` to `userExists` +- Renamed method `hasGroup` to `groupExists` +- Renamed method `hasConnection` to `connnectionExists` + ### Bugs Fixed ### Other Changes