Wiki source code of Configure WebSocket Collaboration with Yjs
Last modified by Eleni Cojocariu on 2025/08/05
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | 1. ((( | ||
2 | Resolve the WebSocket URL using the [[WebSocket script service>>doc:extensions:Extension.WebSocket Integration.WebHome||anchor="HWebSocketScriptService"]]. The identifier of the Yjs WebSocket endpoint is ##yjs##. | ||
3 | |||
4 | {{code language="velocity"}} | ||
5 | $services.websocket.url('yjs') | ||
6 | {{/code}} | ||
7 | ))) | ||
8 | 1. ((( | ||
9 | Use the cristal WebSocket connector, provided by npm dependency [[@xwiki/cristal-collaboration-xwiki>>https://www.npmjs.com/package/@xwiki/cristal-collaboration-xwiki]]. | ||
10 | |||
11 | Installation: | ||
12 | |||
13 | {{code language="bash"}} | ||
14 | npm i --save @xwiki/cristal-collaboration-xwiki | ||
15 | {{/code}} | ||
16 | |||
17 | Use: | ||
18 | |||
19 | {{code language="javascript"}} | ||
20 | import { createXWikiWebsocketProvider } from "@xwiki/cristal-collaboration-xwiki" | ||
21 | |||
22 | const url = "wss://..."; // see step 1. | ||
23 | const room = "My.page"; // the document reference of a page | ||
24 | // The connection is rejected if the current user is not allowed to edit the page. | ||
25 | const provider = createXWikiWebsocketProvider(url, room); | ||
26 | {{/code}} | ||
27 | ))) |