@azure/web-pubsub 1.1.0-alpha.20221107.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +31 -0
- package/dist/index.js +443 -294
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +51 -3
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/index.js +0 -1
- package/dist-esm/src/generated/index.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +2 -0
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +58 -44
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/generated/models/parameters.js +70 -31
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/operations/healthApi.js.map +1 -1
- package/dist-esm/src/generated/operations/webPubSub.js +217 -185
- package/dist-esm/src/generated/operations/webPubSub.js.map +1 -1
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +1 -1
- package/dist-esm/src/groupClient.js.map +1 -1
- package/dist-esm/src/hubClient.js +12 -2
- package/dist-esm/src/hubClient.js.map +1 -1
- package/dist-esm/src/index.js +1 -0
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/utils.js +44 -0
- package/dist-esm/src/utils.js.map +1 -1
- package/dist-esm/test/groups.spec.js +23 -0
- package/dist-esm/test/groups.spec.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +59 -7
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/dist-esm/test/integration.spec.js +99 -7
- package/dist-esm/test/integration.spec.js.map +1 -1
- package/dist-esm/test/odata.spec.js +15 -0
- package/dist-esm/test/odata.spec.js.map +1 -0
- package/package.json +7 -6
- package/types/web-pubsub.d.ts +56 -3
package/README.md
CHANGED
@@ -109,6 +109,9 @@ let token = await serviceClient.getClientAccessToken();
|
|
109
109
|
// Or get the access token and assign the client a userId
|
110
110
|
token = await serviceClient.getClientAccessToken({ userId: "user1" });
|
111
111
|
|
112
|
+
// Or get the access token that the client will join group GroupA when it connects using the access token
|
113
|
+
token = await serviceClient.getClientAccessToken({ userId: "user1", groups: [ "GroupA" ] });
|
114
|
+
|
112
115
|
// return the token to the WebSocket client
|
113
116
|
```
|
114
117
|
|
@@ -130,6 +133,34 @@ const payload = new Uint8Array(10);
|
|
130
133
|
await serviceClient.sendToAll(payload.buffer);
|
131
134
|
```
|
132
135
|
|
136
|
+
### Send messages to all connections in a hub with OData filter syntax
|
137
|
+
|
138
|
+
Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).
|
139
|
+
|
140
|
+
```js
|
141
|
+
const { WebPubSubServiceClient, odata } = require("@azure/web-pubsub");
|
142
|
+
|
143
|
+
const serviceClient = new WebPubSubServiceClient("<ConnectionString>", "<hubName>");
|
144
|
+
|
145
|
+
// Send a JSON message to anonymous connections
|
146
|
+
await serviceClient.sendToAll(
|
147
|
+
{ message: "Hello world!" },
|
148
|
+
{ filter: "userId eq null" }
|
149
|
+
);
|
150
|
+
|
151
|
+
// Send a text message to connections in groupA but not in groupB
|
152
|
+
const groupA = 'groupA';
|
153
|
+
const groupB = 'groupB';
|
154
|
+
await serviceClient.sendToAll(
|
155
|
+
"Hello world!",
|
156
|
+
{
|
157
|
+
contentType: "text/plain",
|
158
|
+
// use plain text "'groupA' in groups and not('groupB' in groups)"
|
159
|
+
// or use the odata helper method
|
160
|
+
filter: odata`${groupA} in groups and not(${groupB} in groups)`
|
161
|
+
});
|
162
|
+
```
|
163
|
+
|
133
164
|
### Send messages to all connections in a group
|
134
165
|
|
135
166
|
```js
|