Skip to content

Commit 57518b7

Browse files
committed
freshness review of reference articles
1 parent 9b63988 commit 57518b7

File tree

4 files changed

+82
-53
lines changed

4 files changed

+82
-53
lines changed

articles/azure-web-pubsub/includes/reference-json-requests.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Format:
1818
}
1919
```
2020

21-
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
21+
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. For details, see [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
2222

2323
### Leave groups
2424

@@ -32,7 +32,7 @@ Format:
3232
}
3333
```
3434

35-
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
35+
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. For details, see [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
3636

3737
### Publish messages
3838

@@ -49,14 +49,15 @@ Format:
4949
}
5050
```
5151

52-
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
53-
* `noEcho` is optional. If set to true, this message is not echoed back to the same connection. If not set, the default value is false.
54-
* `dataType` can be one of `json`, `text`, or `binary`:
52+
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. For details, see [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
53+
* `noEcho` is optional. If set to true, this message isn't echoed back to the same connection. If not set, the default value is false.
54+
* `dataType` can be set to `json`, `text`, or `binary`:
5555
* `json`: `data` can be any type that JSON supports and will be published as what it is; If `dataType` isn't specified, it defaults to `json`.
5656
* `text`: `data` should be in string format, and the string data will be published;
5757
* `binary`: `data` should be in base64 format, and the binary data will be published;
5858

5959
#### Case 1: publish text data:
60+
6061
```json
6162
{
6263
"type": "sendToGroup",
@@ -67,7 +68,8 @@ Format:
6768
}
6869
```
6970

70-
* What subprotocol client in this group `<group_name>` receives:
71+
* The subprotocol clients in `<group_name>` receive:
72+
7173
```json
7274
{
7375
"type": "message",
@@ -77,9 +79,11 @@ Format:
7779
"data" : "text data"
7880
}
7981
```
80-
* What the raw client in this group `<group_name>` receives is string data `text data`.
82+
83+
* The raw clients in `<group_name>` receive the string `text data`.
8184

8285
#### Case 2: publish JSON data:
86+
8387
```json
8488
{
8589
"type": "sendToGroup",
@@ -91,7 +95,8 @@ Format:
9195
}
9296
```
9397

94-
* What subprotocol client in this group `<group_name>` receives:
98+
* The subprotocol clients in `<group_name>` receive:
99+
95100
```json
96101
{
97102
"type": "message",
@@ -103,10 +108,11 @@ Format:
103108
}
104109
}
105110
```
106-
* What the raw client in this group `<group_name>` receives is serialized string data `{"hello": "world"}`.
107111

112+
* The raw clients in `<group_name>` receive the serialized string `{"hello": "world"}`.
108113

109114
#### Case 3: publish binary data:
115+
110116
```json
111117
{
112118
"type": "sendToGroup",
@@ -117,7 +123,8 @@ Format:
117123
}
118124
```
119125

120-
* What subprotocol client in this group `<group_name>` receives:
126+
* The subprotocol clients in `<group_name>` receive:
127+
121128
```json
122129
{
123130
"type": "message",
@@ -127,7 +134,8 @@ Format:
127134
"data" : "<base64_binary>",
128135
}
129136
```
130-
* What the raw client in this group `<group_name>` receives is the **binary** data in the binary frame.
137+
138+
* The raw clients in `<group_name>` receive the **binary** data in the binary frame.
131139

132140
### Send custom events
133141

@@ -143,14 +151,15 @@ Format:
143151
}
144152
```
145153

146-
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. More details can be found at [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
154+
* `ackId` is the identity of each request and should be unique. The service sends a [ack response message](#ack-response) to notify the process result of the request. For details, see [AckId and Ack Response](../concept-client-protocols.md#ackid-and-ack-response)
147155

148156
`dataType` can be one of `text`, `binary`, or `json`:
149-
* `json`: data can be any type json supports and will be published as what it is; If `dataType` is not specified, it defaults to `json`.
150-
* `text`: data should be in string format, and the string data will be published;
151-
* `binary`: data should be in base64 format, and the binary data will be published;
157+
* `json`: data can be any type json supports and will be published as what it is; The default is `json`.
158+
* `text`: data is in string format, and the string data will be published;
159+
* `binary`: data is in base64 format, and the binary data will be published;
152160

153161
#### Case 1: send event with text data:
162+
154163
```json
155164
{
156165
"type": "event",
@@ -161,7 +170,7 @@ Format:
161170
}
162171
```
163172

164-
What the upstream event handler receives like below, the `Content-Type` for the CloudEvents HTTP request is `text/plain` for `dataType`=`text`
173+
The upstream event handler receives data similar to:
165174

166175
```HTTP
167176
POST /upstream HTTP/1.1
@@ -184,6 +193,8 @@ text data
184193
185194
```
186195

196+
The `Content-Type` for the CloudEvents HTTP request is `text/plain` when `dataType` is `text`.
197+
187198
#### Case 2: send event with JSON data:
188199
```json
189200
{
@@ -197,7 +208,7 @@ text data
197208
}
198209
```
199210

200-
What the upstream event handler receives like below, the `Content-Type` for the CloudEvents HTTP request is `application/json` for `dataType`=`json`
211+
The upstream event handler receives data similar to:
201212

202213
```HTTP
203214
POST /upstream HTTP/1.1
@@ -222,6 +233,8 @@ ce-eventName: <event_name>
222233
223234
```
224235

236+
The `Content-Type` for the CloudEvents HTTP request is `application/json` when `dataType` is `json`
237+
225238
#### Case 3: send event with binary data:
226239
```json
227240
{
@@ -233,7 +246,7 @@ ce-eventName: <event_name>
233246
}
234247
```
235248

236-
What the upstream event handler receives like below, the `Content-Type` for the CloudEvents HTTP request is `application/octet-stream` for `dataType`=`binary`
249+
The upstream event handler receives data similar to:
237250

238251
```HTTP
239252
POST /upstream HTTP/1.1
@@ -256,6 +269,6 @@ binary
256269
257270
```
258271

259-
The WebSocket frame can be `text` format for text message frames or UTF8 encoded binaries for `binary` message frames.
272+
The `Content-Type` for the CloudEvents HTTP request is `application/octet-stream` when `dataType` is `binary`. The WebSocket frame can be `text` format for text message frames or UTF8 encoded binaries for `binary` message frames.
260273

261-
Service declines the client if the message does not match the described format.
274+
The Web PubSub service declines the client if the message doesn't match the described format.

articles/azure-web-pubsub/includes/reference-permission.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ ms.date: 08/06/2021
88

99
## Permissions
1010

11-
You may have noticed that when we describe the PubSub WebSocket clients, a client can publish to other clients only when it's *authorized* to. The `role`s of the client determines the *initial* permissions the client have:
11+
A Web PubSub WebSocket client can only publish to other clients when it's authorized to. The `roles` assigned to the client determine the initial permissions granted to the client:
1212

1313
| Role | Permission |
1414
|---|---|
1515
| Not specified | The client can send event requests.
1616
| `webpubsub.joinLeaveGroup` | The client can join/leave any group.
1717
| `webpubsub.sendToGroup` | The client can publish messages to any group.
18-
| `webpubsub.joinLeaveGroup.<group>` | The client can join/leave group `<group>`.
19-
| `webpubsub.sendToGroup.<group>` | The client can publish messages to group `<group>`.
18+
| `webpubsub.joinLeaveGroup.<group>` | The client can join/leave the group `<group>`.
19+
| `webpubsub.sendToGroup.<group>` | The client can publish messages to the group `<group>`.
2020

21-
The server-side can also grant or revoke permissions of the client dynamically through REST APIs or server SDKs.
21+
The server can also dynamically grant or revoke permissions from the client through REST APIs or server SDKs.

articles/azure-web-pubsub/reference-json-reliable-webpubsub-subprotocol.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ author: zackliu
55
ms.author: chenyl
66
ms.service: azure-web-pubsub
77
ms.topic: conceptual
8-
ms.date: 11/06/2021
8+
ms.date: 01/04/2023
99
---
1010

1111
# Azure Web PubSub supported Reliable JSON WebSocket subprotocol
@@ -26,7 +26,7 @@ For example, in JS, a Reliable PubSub WebSocket client can be created using:
2626
var pubsub = new WebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1', 'json.reliable.webpubsub.azure.v1');
2727
```
2828

29-
When using `json.reliable.webpubsub.azure.v1` subprotocol, the client must follow the [How to create reliable clients](./howto-develop-reliable-clients.md) to implement reconnection, publisher and subscriber.
29+
When using `json.reliable.webpubsub.azure.v1` subprotocol, see [How to create reliable clients](./howto-develop-reliable-clients.md) to implement reconnection, publisher and subscriber for clients.
3030

3131
[!INCLUDE [reference-permission](includes/reference-permission.md)]
3232

@@ -45,13 +45,13 @@ Format:
4545
}
4646
```
4747

48-
Reliable PubSub WebSocket client must send sequence ack message once it received a message from the service. Find more in [How to create reliable clients](./howto-develop-reliable-clients.md#subscriber)
48+
Reliable PubSub WebSocket client must send a sequence ack message once it receives a message from the service. Find more in [How to create reliable clients](./howto-develop-reliable-clients.md#subscriber)
4949

5050
* `sequenceId` is a incremental uint64 number from the message received.
5151

5252
## Responses
5353

54-
Messages received by the client can be several types: `ack`, `message`, and `system`. Messages with type `message` have `sequenceId` property. Client must send [Sequence Ack](#sequence-ack) to the service once it receives a message.
54+
Messages received by the client can be several types: `ack`, `message`, and `system`. Messages with type `message` have `sequenceId` property. Client must send a [Sequence Ack](#sequence-ack) to the service once it receives a message.
5555

5656
### Ack response
5757

articles/azure-web-pubsub/reference-json-webpubsub-subprotocol.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@ description: The reference describes Azure Web PubSub supported WebSocket subpro
44
author: vicancy
55
ms.author: lianwei
66
ms.service: azure-web-pubsub
7-
ms.topic: conceptual
8-
ms.date: 11/06/2021
7+
ms.topic: reference
8+
ms.date: 01/06/2023
99
---
1010

11-
# Azure Web PubSub supported JSON WebSocket subprotocol
12-
13-
This document describes the subprotocol `json.webpubsub.azure.v1`.
11+
# Azure Web PubSub supported JSON WebSocket subprotocol
12+
13+
The JSON WebSocket subprotocol, `json.webpubsub.azure.v1`, enables the exchange of publish/subscribe messages directly between clients. A WebSocket connection using the `json.webpubsub.azure.v1` subprotocol is called a PubSub WebSocket client.
1414

15-
When the client is using this subprotocol, both outgoing data frame and incoming data frame are expected to be **JSON** payloads.
15+
This document describes the subprotocol `json.webpubsub.azure.v1`.
1616

1717
## Overview
1818

19-
Subprotocol `json.webpubsub.azure.v1` empowers the clients to do publish/subscribe directly instead of a round trip to the upstream server. We call the WebSocket connection with `json.webpubsub.azure.v1` subprotocol a PubSub WebSocket client.
19+
In a simple native WebSocket client, a *server* role is required to handle events from clients. A simple WebSocket connection triggers a `message` event when it sends messages, and relies on the server-side to process messages and do other operations.
20+
21+
When you use the `json.webpubsub.azure.v1` subprotocol, an authorized client can join a group using [join requests](#join-groups) and publish messages directly to a group using [publish requests](#publish-messages). The client can also route messages directly to upstream event handlers using [event requests](#send-custom-events).
2022

21-
For example, in JS, a PubSub WebSocket client can be created using:
22-
```js
23+
In JavaScript, a PubSub WebSocket client can be created using:
24+
25+
```javascript
2326
// PubSub WebSocket client
2427
var pubsub = new WebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1', 'json.webpubsub.azure.v1');
2528
```
26-
For a simple WebSocket client, the *server* is a MUST HAVE role to handle the events from clients. A simple WebSocket connection always triggers a `message` event when it sends messages, and always relies on the server-side to process messages and do other operations. With the help of the `json.webpubsub.azure.v1` subprotocol, an authorized client can join a group using [join requests](#join-groups) and publish messages to a group using [publish requests](#publish-messages) directly. It can also route messages to different upstream (event handlers) by customizing the *event* the message belongs using [event requests](#send-custom-events).
29+
30+
The following information describes the subprotocol requests and responses. Both incoming and outgoing data frames must contain JSON payloads.
2731

2832
[!INCLUDE [reference-permission](includes/reference-permission.md)]
2933

@@ -33,13 +37,18 @@ For a simple WebSocket client, the *server* is a MUST HAVE role to handle the ev
3337

3438
## Responses
3539

36-
Messages received by the client can be several types: `ack`, `message`, and `system`:
40+
Messages received by the client can be `ack`, `message`, and `system`:
41+
42+
* ack - The response to a request containing an `ackId`.
43+
* message - Messages from the group or server.
44+
* system - Responses from the Web PubSub service to system related client requests.
3745

3846
### Ack response
3947

40-
If the request contains `ackId`, the service will return an ack response for this request. The client implementation should handle this ack mechanism, including waiting for the ack response for an `async` `await` operation, and having a timeout check when the ack response is not received during a certain period.
48+
When the client request contains `ackId`, the service will return an ack response for the request. The client should handle the ack mechanism, by waiting for the ack response with an `async` `await` operation and a using a timeout operation when the ack response isn't received in a certain period.
4149

4250
Format:
51+
4352
```json
4453
{
4554
"type": "ack",
@@ -52,11 +61,11 @@ Format:
5261
}
5362
```
5463

55-
The client implementation SHOULD always check if the `success` is `true` or `false` first. Only when `success` is `false` the client reads from `error`.
64+
The client implementation SHOULD always check if the `success` is `true` or `false` first, then only read the error when `success` is `false`.
5665

5766
### Message response
5867

59-
Clients can receive messages published from one group the client joined, or from the server management role that the server sends messages to the specific client or the specific user.
68+
Clients can receive messages published from a group the client has joined or from the server.
6069

6170
1. When the message is from a group
6271

@@ -71,7 +80,7 @@ Clients can receive messages published from one group the client joined, or from
7180
}
7281
```
7382

74-
1. When The message is from the server.
83+
1. When the message is from the server.
7584

7685
```json
7786
{
@@ -83,8 +92,11 @@ Clients can receive messages published from one group the client joined, or from
8392
```
8493

8594
#### Case 1: Sending data `Hello World` to the connection through REST API with `Content-Type`=`text/plain`
86-
* What a simple WebSocket client receives is a text WebSocket frame with data: `Hello World`;
87-
* What a PubSub WebSocket client receives is as follows:
95+
96+
97+
* A simple WebSocket client receives a text WebSocket frame with data: `Hello World`;
98+
* A PubSub WebSocket client receives:
99+
88100
```json
89101
{
90102
"type": "message",
@@ -95,8 +107,10 @@ Clients can receive messages published from one group the client joined, or from
95107
```
96108

97109
#### Case 2: Sending data `{ "Hello" : "World"}` to the connection through REST API with `Content-Type`=`application/json`
98-
* What a simple WebSocket client receives is a text WebSocket frame with stringified data: `{ "Hello" : "World"}`;
99-
* What a PubSub WebSocket client receives is as follows:
110+
111+
* A simple WebSocket client receives a text WebSocket frame with stringified data: `{ "Hello" : "World"}`.
112+
* A PubSub WebSocket client receives:
113+
100114
```json
101115
{
102116
"type": "message",
@@ -108,11 +122,13 @@ Clients can receive messages published from one group the client joined, or from
108122
}
109123
```
110124

111-
If the REST API is sending a string `Hello World` using `application/json` content type, what the simple WebSocket client receives is a JSON string, which is `"Hello World"` that wraps the string with `"`.
125+
If the REST API is sending a string `Hello World` using `application/json` content type, the simple WebSocket client receives a JSON string, which is `"Hello World"` wrapped with double quotes (`"`).
112126

113127
#### Case 3: Sending binary data to the connection through REST API with `Content-Type`=`application/octet-stream`
114-
* What a simple WebSocket client receives is a binary WebSocket frame with the binary data.
115-
* What a PubSub WebSocket client receives is as follows:
128+
129+
* A simple WebSocket client receives a binary WebSocket frame with the binary data.
130+
* A PubSub WebSocket client receives:
131+
116132
```json
117133
{
118134
"type": "message",
@@ -124,11 +140,11 @@ If the REST API is sending a string `Hello World` using `application/json` conte
124140

125141
### System response
126142

127-
The Web PubSub service can also send system-related responses to the client.
143+
The Web PubSub service sends system related responses to client requests.
128144

129145
#### Connected
130146

131-
When the connection connects to service.
147+
The responses when the client connects to service.
132148

133149
```json
134150
{
@@ -141,7 +157,7 @@ When the connection connects to service.
141157

142158
#### Disconnected
143159

144-
When the server closes the connection, or when the service declines the client.
160+
The response when the server closes the connection, or when the service declines the client.
145161

146162
```json
147163
{

0 commit comments

Comments
 (0)