@@ -8,20 +8,20 @@ versioned as a whole.
88This is a _ draft_ protocol.
99This specific version is identified by the string ` solid-ws-draft/v0.1.0-alpha ` .
1010
11- ## Subscribing
11+ ## Protocol description
1212
1313Live updates are currently only supported through WebSockets. This describes a
1414subscription mechanism through which clients can be notified in real time of
1515changes affecting a given resource.
1616
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:
2525
2626REQUEST:
2727
@@ -35,9 +35,24 @@ RESPONSE:
3535``` http
3636HTTP/1.1 200 OK
3737...
38- Updates-Via: wss://example.org/
38+ Updates-Via: wss://example.org
3939```
4040
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+
4156To subscribe to a resource, clients will need to send the keyword ` sub ` followed
4257by an empty space and then the URI of the resource:
4358
@@ -81,6 +96,7 @@ Then the following notification message will be sent:
8196pub https://example.org/data/
8297```
8398
99+ ### Example
84100Here is a Javascript example on how to subscribe to live updates for a ` test `
85101resource at ` https://example.org/data/test ` :
86102
0 commit comments