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/concept-client-protocols.md
+3-13Lines changed: 3 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,32 +61,22 @@ var client2 = new WebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1', '
61
61
62
62
Simple WebSocket client has two modes: `sendEvent` and `sendToGroup`. The mode is determined once the connection is established and cannot be changed later.
63
63
64
-
`sendEvent` is the default mode for the simple WebSocket client. In `sendEvent` mode, every WebSocket frame the client sent is considered as a `message` event by default. Users can configure [event handlers](./concept-service-internals.md#event-handler) or [event listeners](./concept-service-internals.md#event-listener) to handle these `message` events.
64
+
`sendEvent` is the default mode for the simple WebSocket client. In `sendEvent` mode, every WebSocket frame the client sent is considered as a `message` event. Users can configure [event handlers](./concept-service-internals.md#event-handler) or [event listeners](./concept-service-internals.md#event-listener) to handle these `message` events.
65
65
66
66
You can also customize the event name by using `event` query parameter.
67
67
```javascript
68
68
// When every data frame is considered as a `message` event
69
69
var client3 =newWebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1');
70
70
71
-
// When every data frame is considered as a `chat` event
72
-
var client4 =newWebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1?event=chat');
In `sendToGroup` mode, every WebSocket frame the client sent is considered as a message to be published to a specific group. `group` is a required query parameter in this mode, and only a single value is allowed. The connection should also have corresponding [permissions](#permissions) to send messages to the target group. Both `webpubsub.sendToGroup.<group>` and `webpubsub.sendToGroup` roles work for it.
79
76
80
77
For example, in JavaScript, you can create a simple WebSocket client in `sendToGroup` mode with `group=group1` by using the following code:
81
78
```javascript
82
-
// simple WebSocket client4 in sendToGroup mode. Messages sent from client3 will be fixedly forwarded to group1
83
-
var client6 =newWebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1?webpubsub_mode=sendToGroup&group=group1');
84
-
```
85
-
86
-
The default mode of a simple WebSocket client is `sendEvent` with parameter `event=message`. For example, in JavaScript, the following code creates two clients in the same mode with the same corresponding parameter.
87
-
```javascript
88
-
var client7 =newWebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1');
89
-
var client8 =newWebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1?webpubsub_mode=sendEvent&event=message');
79
+
var client5 =newWebSocket('wss://test.webpubsub.azure.com/client/hubs/hub1?webpubsub_mode=sendToGroup&group=group1');
0 commit comments