Skip to content

Commit

Permalink
[Web Pubsub Express] Preparing for beta.4 release (#18417)
Browse files Browse the repository at this point in the history
  • Loading branch information
vicancy authored Nov 2, 2021
1 parent 60b814f commit 446eed1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
24 changes: 23 additions & 1 deletion sdk/web-pubsub/web-pubsub-express/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions sdk/web-pubsub/web-pubsub-express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ const express = require("express");
const { WebPubSubEventHandler } = require("@azure/web-pubsub-express");
const handler = new WebPubSubEventHandler(
"chat",
["https://<yourAllowedService>.webpubsub.azure.com"],
{
handleConnect: (req, res) => {
// auth the connection and set the userId of the connection
res.success({
userId: "<userId>"
});
}
},
allowedEndpoints: ["https://<yourAllowedService>.webpubsub.azure.com"]
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
11 changes: 9 additions & 2 deletions sdk/web-pubsub/web-pubsub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 446eed1

Please sign in to comment.