@@ -8,20 +8,20 @@ versioned as a whole.
8
8
This is a _ draft_ protocol.
9
9
This specific version is identified by the string ` solid-ws-draft/v0.1.0-alpha ` .
10
10
11
- ## Subscribing
11
+ ## Protocol description
12
12
13
13
Live updates are currently only supported through WebSockets. This describes a
14
14
subscription mechanism through which clients can be notified in real time of
15
15
changes affecting a given resource.
16
16
17
- The PubSub system is very basic. Clients only need to open a WebSocket
18
- connection and * sub * (scribe) to a given resource URI. If any change occurs in
19
- that resource , a * pub * (lish) event will be sent to all the subscribed clients .
20
-
21
- The WebSocket server URI is the same for any resource located on a given data
22
- space (same hostname). To discover the URI of the WebSocket server, clients can
23
- send an HTTP OPTIONS request. The server will then include an ` Updates-Via ` header in
24
- the response:
17
+ ### Discovery
18
+ The PubSub system is very basic.
19
+ First , a client needs to obtain the URI of the WebSocket .
20
+ The WebSocket server URI is the same for any resource
21
+ located on a given data space (same hostname).
22
+ To discover the URI of the WebSocket server,
23
+ clients can send an HTTP ` OPTIONS ` request.
24
+ The server will then include an ` Updates-Via ` header in the response:
25
25
26
26
REQUEST:
27
27
@@ -35,9 +35,24 @@ RESPONSE:
35
35
``` http
36
36
HTTP/1.1 200 OK
37
37
...
38
- Updates-Via: wss://example.org/
38
+ Updates-Via: wss://example.org
39
39
```
40
40
41
+ ### Connection
42
+ Then, the client needs to open a WebSocket connection
43
+ to that URI.
44
+
45
+ For example, in JavaScript, this could be done as follows:
46
+
47
+ ```
48
+ const socket = new WebSocket('wss://example.org');
49
+ ```
50
+
51
+ ### Subscription
52
+ Then, the client needs to * sub* (scribe) to a given resource URI.
53
+ If any change occurs in that resource,
54
+ a * pub* (lish) event will be sent to all the subscribed clients.
55
+
41
56
To subscribe to a resource, clients will need to send the keyword ` sub ` followed
42
57
by an empty space and then the URI of the resource:
43
58
@@ -81,6 +96,7 @@ Then the following notification message will be sent:
81
96
pub https://example.org/data/
82
97
```
83
98
99
+ ### Example
84
100
Here is a Javascript example on how to subscribe to live updates for a ` test `
85
101
resource at ` https://example.org/data/test ` :
86
102
0 commit comments