You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/reference-json-requests.md
+34-20Lines changed: 34 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Format:
18
18
}
19
19
```
20
20
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)
22
22
23
23
### Leave groups
24
24
@@ -32,7 +32,7 @@ Format:
32
32
}
33
33
```
34
34
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)
36
36
37
37
### Publish messages
38
38
@@ -49,14 +49,15 @@ Format:
49
49
}
50
50
```
51
51
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`:
55
55
*`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`.
56
56
*`text`: `data` should be in string format, and the string data will be published;
57
57
*`binary`: `data` should be in base64 format, and the binary data will be published;
58
58
59
59
#### Case 1: publish text data:
60
+
60
61
```json
61
62
{
62
63
"type": "sendToGroup",
@@ -67,7 +68,8 @@ Format:
67
68
}
68
69
```
69
70
70
-
* What subprotocol client in this group `<group_name>` receives:
71
+
* The subprotocol clients in `<group_name>` receive:
72
+
71
73
```json
72
74
{
73
75
"type": "message",
@@ -77,9 +79,11 @@ Format:
77
79
"data" : "text data"
78
80
}
79
81
```
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`.
81
84
82
85
#### Case 2: publish JSON data:
86
+
83
87
```json
84
88
{
85
89
"type": "sendToGroup",
@@ -91,7 +95,8 @@ Format:
91
95
}
92
96
```
93
97
94
-
* What subprotocol client in this group `<group_name>` receives:
98
+
* The subprotocol clients in `<group_name>` receive:
99
+
95
100
```json
96
101
{
97
102
"type": "message",
@@ -103,10 +108,11 @@ Format:
103
108
}
104
109
}
105
110
```
106
-
* What the raw client in this group `<group_name>` receives is serialized string data `{"hello": "world"}`.
107
111
112
+
* The simple WebSocket clients in `<group_name>` receive the serialized string `{"hello": "world"}`.
108
113
109
114
#### Case 3: publish binary data:
115
+
110
116
```json
111
117
{
112
118
"type": "sendToGroup",
@@ -117,7 +123,8 @@ Format:
117
123
}
118
124
```
119
125
120
-
* What subprotocol client in this group `<group_name>` receives:
126
+
* The subprotocol clients in `<group_name>` receive:
127
+
121
128
```json
122
129
{
123
130
"type": "message",
@@ -127,7 +134,8 @@ Format:
127
134
"data" : "<base64_binary>",
128
135
}
129
136
```
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.
131
139
132
140
### Send custom events
133
141
@@ -143,14 +151,16 @@ Format:
143
151
}
144
152
```
145
153
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)
147
155
148
156
`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;
152
161
153
162
#### Case 1: send event with text data:
163
+
154
164
```json
155
165
{
156
166
"type": "event",
@@ -161,7 +171,7 @@ Format:
161
171
}
162
172
```
163
173
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:
165
175
166
176
```HTTP
167
177
POST /upstream HTTP/1.1
@@ -184,6 +194,8 @@ text data
184
194
185
195
```
186
196
197
+
The `Content-Type` for the CloudEvents HTTP request is `text/plain` when `dataType` is `text`.
198
+
187
199
#### Case 2: send event with JSON data:
188
200
```json
189
201
{
@@ -197,7 +209,7 @@ text data
197
209
}
198
210
```
199
211
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:
201
213
202
214
```HTTP
203
215
POST /upstream HTTP/1.1
@@ -222,6 +234,8 @@ ce-eventName: <event_name>
222
234
223
235
```
224
236
237
+
The `Content-Type` for the CloudEvents HTTP request is `application/json` when `dataType` is `json`
238
+
225
239
#### Case 3: send event with binary data:
226
240
```json
227
241
{
@@ -233,7 +247,7 @@ ce-eventName: <event_name>
233
247
}
234
248
```
235
249
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:
237
251
238
252
```HTTP
239
253
POST /upstream HTTP/1.1
@@ -256,6 +270,6 @@ binary
256
270
257
271
```
258
272
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.
260
274
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.
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/reference-permission.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,14 +8,14 @@ ms.date: 08/06/2021
8
8
9
9
## Permissions
10
10
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:
12
12
13
13
| Role | Permission |
14
14
|---|---|
15
15
| Not specified | The client can send event requests.
16
16
| `webpubsub.joinLeaveGroup` | The client can join/leave any group.
17
17
| `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>`.
20
20
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.
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/includes/reference-protobuf-requests.md
+23-20Lines changed: 23 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,23 +18,23 @@ Set `leave_group_message.group` to the group name.
18
18
19
19
Format:
20
20
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)
22
22
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.
24
24
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.
26
26
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.
28
28
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.
30
30
31
31
#### Case 1: Publish text data
32
32
33
33
Set `send_to_group_message.group` to `group`, and set `send_to_group_message.data.text_data` to `"text data"`.
34
34
35
35
* The protobuf subprotocol client in group `group` receives the binary frame and can use [DownstreamMessage](#responses) to deserialize it.
36
36
37
-
* The JSON subprotocol client in group `group`receives:
37
+
* The JSON subprotocol clients in `group`receive:
38
38
39
39
```json
40
40
{
@@ -46,11 +46,11 @@ Set `send_to_group_message.group` to `group`, and set `send_to_group_message.dat
46
46
}
47
47
```
48
48
49
-
* The raw client in group `group` receives string `text data`.
49
+
* The simple WebSocket clients in `group` receive string `text data`.
50
50
51
51
#### Case 2: Publish protobuf data
52
52
53
-
Let's assume that you have a customer message:
53
+
Let's assume that you have a custom message:
54
54
55
55
```
56
56
message MyMessage {
@@ -60,9 +60,9 @@ message MyMessage {
60
60
61
61
Set `send_to_group_message.group` to `group` and `send_to_group_message.data.protobuf_data` to `Any.pack(MyMessage)` with `value = 1`.
62
62
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.
64
64
65
-
* The subprotocol client in group `group` receives:
65
+
* The subprotocol client in `group` receives:
66
66
67
67
```json
68
68
{
@@ -87,7 +87,7 @@ message MyMessage {
87
87
}
88
88
```
89
89
90
-
* The raw client in group `group`receives the binary frame:
90
+
* The simple WebSocket clients in `group`receive the binary frame:
91
91
92
92
```
93
93
# Show in hexadecimal
@@ -114,7 +114,7 @@ Set `send_to_group_message.group` to `group`, and set `send_to_group_message.dat
114
114
115
115
Because the JSON subprotocol client supports only text-based messaging, the binary is always Base64-encoded.
116
116
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:
118
118
119
119
```
120
120
# Show in hexadecimal
@@ -125,17 +125,17 @@ Set `send_to_group_message.group` to `group`, and set `send_to_group_message.dat
125
125
126
126
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.
127
127
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.
129
129
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.
131
131
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.
133
133
134
134
#### Case 1: Send an event with text data
135
135
136
136
Set `event_message.data.text_data` to `"text data"`.
137
137
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:
139
139
140
140
```HTTP
141
141
POST /upstream HTTP/1.1
@@ -158,6 +158,8 @@ text data
158
158
159
159
```
160
160
161
+
The `Content-Type` for the CloudEvents HTTP request is `text/plain`, where `dataType`=`text`.
162
+
161
163
#### Case 2: Send an event with protobuf data
162
164
163
165
Assume that you've received the following customer message:
@@ -170,7 +172,7 @@ message MyMessage {
170
172
171
173
Set `event_message.data.protobuf_data` to `any.pack(MyMessage)` with `value = 1`
172
174
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:
The `Content-Type` for the CloudEvents HTTP request is `application/x-protobuf`, where `dataType`=`protobuf`.
199
+
196
200
The data is a valid protobuf binary. You can use the following `proto` and `any.unpack()` to deserialize it:
197
201
198
202
```protobuf
@@ -207,7 +211,7 @@ message MyMessage {
207
211
208
212
Set `send_to_group_message.binary_data` to `[1, 2, 3]`.
209
213
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:
211
215
212
216
```HTTP
213
217
POST /upstream HTTP/1.1
@@ -229,7 +233,6 @@ ce-eventName: <event_name>
229
233
// Just show in hexadecimal; you need to read it as binary
230
234
01 02 03
231
235
```
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.
234
237
235
238
The service declines the client if the message doesn't match the prescribed format.
0 commit comments