@azure/web-pubsub 1.1.4-alpha.20250408.1 → 1.1.4-alpha.20250416.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -7
- package/package.json +2 -1
package/README.md
CHANGED
@@ -100,8 +100,13 @@ When the client is connected, it can send messages to the upstream application,
|
|
100
100
|
|
101
101
|
```ts snippet:ReadmeSampleGetClientAccessToken
|
102
102
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
103
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
103
104
|
|
104
|
-
const serviceClient = new WebPubSubServiceClient(
|
105
|
+
const serviceClient = new WebPubSubServiceClient(
|
106
|
+
"<Endpoint>",
|
107
|
+
new DefaultAzureCredential(),
|
108
|
+
"<hubName>",
|
109
|
+
);
|
105
110
|
|
106
111
|
// Get the access token for the WebSocket client connection to use
|
107
112
|
let token = await serviceClient.getClientAccessToken();
|
@@ -117,8 +122,13 @@ token = await serviceClient.getClientAccessToken({ userId: "user1", groups: ["Gr
|
|
117
122
|
|
118
123
|
```ts snippet:ReadmeSampleSendToAll
|
119
124
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
125
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
120
126
|
|
121
|
-
const serviceClient = new WebPubSubServiceClient(
|
127
|
+
const serviceClient = new WebPubSubServiceClient(
|
128
|
+
"<Endpoint>",
|
129
|
+
new DefaultAzureCredential(),
|
130
|
+
"<hubName>",
|
131
|
+
);
|
122
132
|
|
123
133
|
// Send a JSON message
|
124
134
|
await serviceClient.sendToAll({ message: "Hello world!" });
|
@@ -137,8 +147,13 @@ Details about `filter` syntax please see [OData filter syntax for Azure Web PubS
|
|
137
147
|
|
138
148
|
```ts snippet:ReadmeSampleSendToAllWithFilter
|
139
149
|
import { WebPubSubServiceClient, odata } from "@azure/web-pubsub";
|
150
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
140
151
|
|
141
|
-
const serviceClient = new WebPubSubServiceClient(
|
152
|
+
const serviceClient = new WebPubSubServiceClient(
|
153
|
+
"<Endpoint>",
|
154
|
+
new DefaultAzureCredential(),
|
155
|
+
"<hubName>",
|
156
|
+
);
|
142
157
|
|
143
158
|
// Send a JSON message to anonymous connections
|
144
159
|
await serviceClient.sendToAll({ message: "Hello world!" }, { filter: "userId eq null" });
|
@@ -158,8 +173,13 @@ await serviceClient.sendToAll("Hello world!", {
|
|
158
173
|
|
159
174
|
```ts snippet:ReadmeSampleSendToGroup
|
160
175
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
176
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
161
177
|
|
162
|
-
const serviceClient = new WebPubSubServiceClient(
|
178
|
+
const serviceClient = new WebPubSubServiceClient(
|
179
|
+
"<Endpoint>",
|
180
|
+
new DefaultAzureCredential(),
|
181
|
+
"<hubName>",
|
182
|
+
);
|
163
183
|
|
164
184
|
const groupClient = serviceClient.group("<groupName>");
|
165
185
|
|
@@ -181,8 +201,13 @@ await groupClient.sendToAll(payload.buffer);
|
|
181
201
|
|
182
202
|
```ts snippet:ReadmeSampleSendToUser
|
183
203
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
204
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
184
205
|
|
185
|
-
const serviceClient = new WebPubSubServiceClient(
|
206
|
+
const serviceClient = new WebPubSubServiceClient(
|
207
|
+
"<Endpoint>",
|
208
|
+
new DefaultAzureCredential(),
|
209
|
+
"<hubName>",
|
210
|
+
);
|
186
211
|
|
187
212
|
// Send a JSON message
|
188
213
|
await serviceClient.sendToUser("user1", { message: "Hello world!" });
|
@@ -199,8 +224,13 @@ await serviceClient.sendToUser("user1", payload.buffer);
|
|
199
224
|
|
200
225
|
```ts snippet:ReadmeSampleCheckGroup
|
201
226
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
227
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
202
228
|
|
203
|
-
const serviceClient = new WebPubSubServiceClient(
|
229
|
+
const serviceClient = new WebPubSubServiceClient(
|
230
|
+
"<Endpoint>",
|
231
|
+
new DefaultAzureCredential(),
|
232
|
+
"<hubName>",
|
233
|
+
);
|
204
234
|
|
205
235
|
const groupClient = serviceClient.group("<groupName>");
|
206
236
|
|
@@ -215,8 +245,13 @@ const hasConnections = await serviceClient.groupExists("<groupName>");
|
|
215
245
|
|
216
246
|
```ts snippet:ReadmeSampleRawResponse
|
217
247
|
import { WebPubSubServiceClient } from "@azure/web-pubsub";
|
248
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
218
249
|
|
219
|
-
const serviceClient = new WebPubSubServiceClient(
|
250
|
+
const serviceClient = new WebPubSubServiceClient(
|
251
|
+
"<Endpoint>",
|
252
|
+
new DefaultAzureCredential(),
|
253
|
+
"<hubName>",
|
254
|
+
);
|
220
255
|
|
221
256
|
function onResponse(rawResponse) {
|
222
257
|
console.log(rawResponse);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/web-pubsub",
|
3
|
-
"version": "1.1.4-alpha.
|
3
|
+
"version": "1.1.4-alpha.20250416.1",
|
4
4
|
"description": "Azure client library for Azure Web PubSub",
|
5
5
|
"sdk-type": "client",
|
6
6
|
"main": "./dist/commonjs/index.js",
|
@@ -75,6 +75,7 @@
|
|
75
75
|
"@azure-tools/test-credential": "^2.0.0",
|
76
76
|
"@azure-tools/test-recorder": ">=4.1.0-alpha <4.1.0-alphb",
|
77
77
|
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
|
78
|
+
"@azure/arm-webpubsub": "^1.2.0",
|
78
79
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
79
80
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
80
81
|
"@azure/identity": "^4.7.0",
|