Skip to content

Commit 4e63622

Browse files
authored
Merge pull request #223135 from cebundy/wps-ref-review
[Web PubSub]: freshness review of reference articles
2 parents 93c5870 + 838b9a2 commit 4e63622

File tree

5 files changed

+149
-97
lines changed

5 files changed

+149
-97
lines changed

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

Lines changed: 34 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 simple WebSocket 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 simple WebSocket 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 simple WebSocket clients in `<group_name>` receive the **binary** data in the binary frame.
131139

132140
### Send custom events
133141

@@ -143,14 +151,16 @@ 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+
158+
* `json`: data can be any type json supports and will be published as what it is; The default is `json`.
159+
* `text`: data is in string format, and the string data will be published;
160+
* `binary`: data is in base64 format, and the binary data will be published;
152161

153162
#### Case 1: send event with text data:
163+
154164
```json
155165
{
156166
"type": "event",
@@ -161,7 +171,7 @@ Format:
161171
}
162172
```
163173

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

166176
```HTTP
167177
POST /upstream HTTP/1.1
@@ -184,6 +194,8 @@ text data
184194
185195
```
186196

197+
The `Content-Type` for the CloudEvents HTTP request is `text/plain` when `dataType` is `text`.
198+
187199
#### Case 2: send event with JSON data:
188200
```json
189201
{
@@ -197,7 +209,7 @@ text data
197209
}
198210
```
199211

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

202214
```HTTP
203215
POST /upstream HTTP/1.1
@@ -222,6 +234,8 @@ ce-eventName: <event_name>
222234
223235
```
224236

237+
The `Content-Type` for the CloudEvents HTTP request is `application/json` when `dataType` is `json`
238+
225239
#### Case 3: send event with binary data:
226240
```json
227241
{
@@ -233,7 +247,7 @@ ce-eventName: <event_name>
233247
}
234248
```
235249

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

238252
```HTTP
239253
POST /upstream HTTP/1.1
@@ -256,6 +270,6 @@ binary
256270
257271
```
258272

259-
The WebSocket frame can be `text` format for text message frames or UTF8 encoded binaries for `binary` message frames.
273+
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.
260274

261-
Service declines the client if the message does not match the described format.
275+
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 PubSub WebSocket client can only publish to other clients when it's authorized. The `roles` assigned to the client determine the 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 dynamically grant or revoke client permissions through REST APIs or server SDKs.

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

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ Set `leave_group_message.group` to the group name.
1818

1919
Format:
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`: The unique identity of each request. 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)
2222

23-
There's an implicit `dataType`, which can be `protobuf`, `text`, or `binary`, depending on the `data` in `MessageData` you set. The receiver clients can use `dataType` to handle the content correctly.
23+
* `dataType`: The data format, which can be `protobuf`, `text`, or `binary` depending on the `data` in `MessageData`. The receiving clients can use `dataType` to correctly process the content.
2424

25-
* `protobuf`: If you set `send_to_group_message.data.protobuf_data`, the implicit `dataType` is `protobuf`. `protobuf_data` can be of the [Any](https://developers.google.com/protocol-buffers/docs/proto3#any) message type. All other clients receive a protobuf-encoded binary, which can be deserialized by the protobuf SDK. Clients that support only text-based content (for example, `json.webpubsub.azure.v1`) receive a Base64-encoded binary.
25+
* `protobuf`: When you set `send_to_group_message.data.protobuf_data`, the implicit `dataType` is `protobuf`. `protobuf_data` can be of the [Any](https://developers.google.com/protocol-buffers/docs/proto3#any) message type. All other clients receive a protobuf-encoded binary, which can be deserialized by the protobuf SDK. Clients that support only text-based content (for example, `json.webpubsub.azure.v1`) receive a Base64-encoded binary.
2626

27-
* `text`: If you set `send_to_group_message.data.text_data`, the implicit `dataType` is `text`. `text_data` should be a string. All clients with other protocols receive a UTF-8-encoded string.
27+
* `text`: When you set `send_to_group_message.data.text_data`, the implicit `dataType` is `text`. `text_data` should be a string. All clients with other protocols receive a UTF-8-encoded string.
2828

29-
* `binary`: If you set `send_to_group_message.data.binary_data`, the implicit `dataType` is `binary`. `binary_data` should be a byte array. All clients with other protocols receive a raw binary without protobuf encoding. Clients that support only text-based content (for example, `json.webpubsub.azure.v1`) receive a Base64-encoded binary.
29+
* `binary`: When you set `send_to_group_message.data.binary_data`, the implicit `dataType` is `binary`. `binary_data` should be a byte array. All clients with other protocols receive a raw binary without protobuf encoding. Clients that support only text-based content (for example, `json.webpubsub.azure.v1`) receive a Base64-encoded binary.
3030

3131
#### Case 1: Publish text data
3232

3333
Set `send_to_group_message.group` to `group`, and set `send_to_group_message.data.text_data` to `"text data"`.
3434

3535
* The protobuf subprotocol client in group `group` receives the binary frame and can use [DownstreamMessage](#responses) to deserialize it.
3636

37-
* The JSON subprotocol client in group `group` receives:
37+
* The JSON subprotocol clients in `group` receive:
3838

3939
```json
4040
{
@@ -46,11 +46,11 @@ Set `send_to_group_message.group` to `group`, and set `send_to_group_message.dat
4646
}
4747
```
4848

49-
* The raw client in group `group` receives string `text data`.
49+
* The simple WebSocket clients in `group` receive string `text data`.
5050

5151
#### Case 2: Publish protobuf data
5252

53-
Let's assume that you have a customer message:
53+
Let's assume that you have a custom message:
5454

5555
```
5656
message MyMessage {
@@ -60,9 +60,9 @@ message MyMessage {
6060
6161
Set `send_to_group_message.group` to `group` and `send_to_group_message.data.protobuf_data` to `Any.pack(MyMessage)` with `value = 1`.
6262
63-
* The protobuf subprotocol client in group `group` receives the binary frame and can use [DownstreamMessage](#responses) to deserialize it.
63+
* The protobuf subprotocol clients in `group` receive the binary frame and can use [DownstreamMessage](#responses) to deserialize it.
6464
65-
* The subprotocol client in group `group` receives:
65+
* The subprotocol client in `group` receives:
6666
6767
```json
6868
{
@@ -87,7 +87,7 @@ message MyMessage {
8787
}
8888
```
8989

90-
* The raw client in group `group` receives the binary frame:
90+
* The simple WebSocket clients in `group` receive the binary frame:
9191

9292
```
9393
# Show in hexadecimal
@@ -114,7 +114,7 @@ Set `send_to_group_message.group` to `group`, and set `send_to_group_message.dat
114114
115115
Because the JSON subprotocol client supports only text-based messaging, the binary is always Base64-encoded.
116116
117-
* The raw client in group `group` receives the binary data in the binary frame:
117+
* The simple WebSocket clients in `group` receive the binary data in the binary frame:
118118
119119
```
120120
# Show in hexadecimal
@@ -125,17 +125,17 @@ Set `send_to_group_message.group` to `group`, and set `send_to_group_message.dat
125125
126126
There's an implicit `dataType`, which can be `protobuf`, `text`, or `binary`, depending on the `dataType` you set. The receiver clients can use `dataType` to handle the content correctly.
127127
128-
* `protobuf`: If you set `event_message.data.protobuf_data`, the implicit `dataType` is `protobuf`. `protobuf_data` can be any supported protobuf type. The event handler receives the protobuf-encoded binary, which can be deserialized by any protobuf SDK.
128+
* `protobuf`: When you set `event_message.data.protobuf_data`, the implicit `dataType` is `protobuf`. The `protobuf_data` value can be any supported protobuf type. The event handler receives the protobuf-encoded binary, which can be deserialized by any protobuf SDK.
129129
130-
* `text`: If you set `event_message.data.text_data`, the implicit is `text`. `text_data` should be a string. The event handler receives a UTF-8-encoded string;
130+
* `text`: When you set `event_message.data.text_data`, the implicit `dataType` is `text`. The `text_data` value should be a string. The event handler receives a UTF-8-encoded string.
131131
132-
* `binary`: If you set `event_message.data.binary_data`, the implicit is `binary`. `binary_data` should be a byte array. The event handler receives the raw binary frame.
132+
* `binary`: When you set `event_message.data.binary_data`, the implicit `dataType` is `binary`. The `binary_data` value should be a byte array. The event handler receives the simple WebSocket binary frame.
133133
134134
#### Case 1: Send an event with text data
135135
136136
Set `event_message.data.text_data` to `"text data"`.
137137
138-
The upstream event handler receives a request that's similar to the following. Note that `Content-Type` for the CloudEvents HTTP request is `text/plain`, where `dataType`=`text`.
138+
The upstream event handler receives a request similar to:
139139
140140
```HTTP
141141
POST /upstream HTTP/1.1
@@ -158,6 +158,8 @@ text data
158158
159159
```
160160

161+
The `Content-Type` for the CloudEvents HTTP request is `text/plain`, where `dataType`=`text`.
162+
161163
#### Case 2: Send an event with protobuf data
162164

163165
Assume that you've received the following customer message:
@@ -170,7 +172,7 @@ message MyMessage {
170172

171173
Set `event_message.data.protobuf_data` to `any.pack(MyMessage)` with `value = 1`
172174

173-
The upstream event handler receives a request that's similar to the following. Note that the `Content-Type` for the CloudEvents HTTP request is `application/x-protobuf`, where `dataType`=`protobuf`.
175+
The upstream event handler receives a request that's similar to:
174176

175177
```HTTP
176178
POST /upstream HTTP/1.1
@@ -193,6 +195,8 @@ ce-eventName: <event_name>
193195
0A 2F 74 79 70 65 2E 67 6F 6F 67 6C 65 61 70 69 73 2E 63 6F 6D 2F 61 7A 75 72 65 2E 77 65 62 70 75 62 73 75 62 2E 54 65 73 74 4D 65 73 73 61 67 65 12 02 08 01
194196
```
195197

198+
The `Content-Type` for the CloudEvents HTTP request is `application/x-protobuf`, where `dataType`=`protobuf`.
199+
196200
The data is a valid protobuf binary. You can use the following `proto` and `any.unpack()` to deserialize it:
197201

198202
```protobuf
@@ -207,7 +211,7 @@ message MyMessage {
207211

208212
Set `send_to_group_message.binary_data` to `[1, 2, 3]`.
209213

210-
The upstream event handler receives a request similar to the following. For `dataType`=`binary`, the `Content-Type` for the CloudEvents HTTP request is `application/octet-stream`.
214+
The upstream event handler receives a request similar to:
211215

212216
```HTTP
213217
POST /upstream HTTP/1.1
@@ -229,7 +233,6 @@ ce-eventName: <event_name>
229233
// Just show in hexadecimal; you need to read it as binary
230234
01 02 03
231235
```
232-
233-
The WebSocket frame can be in `text` format for text message frames or UTF-8-encoded binaries for `binary` message frames.
236+
For `dataType`=`binary`, the `Content-Type` for the CloudEvents HTTP request is `application/octet-stream`. The WebSocket frame can be in `text` format for text message frames or UTF-8-encoded binaries for `binary` message frames.
234237

235238
The service declines the client if the message doesn't match the prescribed format.

0 commit comments

Comments
 (0)