@@ -222,28 +222,44 @@ For example:
222
222
## 3. Websockets
223
223
224
224
A HTTP request can be promoted into a websocket by means of an
225
- "upgrade" header.
225
+ "" upgrade" header.
226
226
227
227
In this situation, a Ring handler may choose to respond with a
228
228
websocket response instead of a HTTP response.
229
229
230
230
### 3.1. Websocket Responses
231
231
232
- A websocket response is a map that has the ` :ring.websocket/listener `
233
- key, which maps to a websocket listener, described in section 3.2 .
232
+ A websocket response is a map that represents a WebSocket, and may be
233
+ returned from a handler in place of a response map .
234
234
235
235
``` clojure
236
236
(fn [request]
237
237
#:ring.websocket{:listener websocket-listener})
238
238
```
239
239
240
- A websocket response may be returned from a synchronous listener, or
241
- via the response callback of an asynchronous listener.
240
+ It may also be used from an asynchronous handler.
242
241
243
242
``` clojure
244
243
(fn [request respond raise]
245
244
(respond #:ring.websocket{:listener websocket-listener}))
246
- ```
245
+
246
+ A websocket response contains the following keys. Any key not marked as
247
+ **required** may be omitted.
248
+
249
+ | Key | Type | Required |
250
+ | ------------------------ | ----------------------- | -------- |
251
+ |`:ring.websocket/listener`|`ring.websocket/Listener`| Yes |
252
+ |`:ring.websocket/protocol`|`String` | |
253
+
254
+ #### :ring.websocket/listener
255
+
256
+ An event listener that satisfies the `ring.websocket/Listener` protocol,
257
+ as described in section 3.2 .
258
+
259
+ #### :ring.websocket/protocol
260
+
261
+ An optional websocket subprotocol. Must be one of the values listed in
262
+ the `Sec-Websocket-Protocol` header on the request.
247
263
248
264
### 3.2 . Websocket Listeners
249
265
0 commit comments