|
| 1 | +# Open Collaboration Service Process |
| 2 | + |
| 3 | +Open Collaboration Tools is a collection of open source tools, libraries and extensions for live-sharing of IDE contents, designed to boost remote teamwork with open technologies. For more information about this project, please [read the announcement](https://www.typefox.io/blog/open-collaboration-tools-announcement/). |
| 4 | + |
| 5 | +This package is a standalone Node.js application, which helps to simplify integration of OCT with non-TypeScript environments, by providing a stdin/stdout based [JSON-RPC](https://www.jsonrpc.org/) API. |
| 6 | + |
| 7 | +It takes over encryption, session lifecycle management, and includes Yjs integration for collision-free real-time editing of documents, |
| 8 | +so client applications do not need to implement these complex features themselves. |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +### Starting the Service Process |
| 13 | + |
| 14 | +Start the process by either using [Node.js](https://nodejs.org) to call `process.js` or use a prebuilt executable: |
| 15 | + |
| 16 | +```sh |
| 17 | +node ./lib/process.js --server-address http://localhost:8100 --auth-token <your-auth-token> |
| 18 | +``` |
| 19 | + |
| 20 | +- `--server-address` (**required**): The address of the collaboration server to connect to (e.g., `https://api.open-collab.tools`). |
| 21 | +- `--auth-token` (**optional**): The authentication token to use for the session, if saved by the application from a previous login |
| 22 | + |
| 23 | +### Communication Protocol |
| 24 | + |
| 25 | +All communication happens via JSON-RPC 2.0 messages over stdin/stdout. |
| 26 | +See [messages.ts](src/messages.ts) for service process specific awarness or lifecycle messages. Other messages follow the open-collaboration-protocol. |
| 27 | + |
| 28 | +For specific examples see `service.process.test.ts` or the [IntellIj integration](https://github.com/eclipse-oct/oct-intellij) |
| 29 | + |
| 30 | +### Sending and Receiving Binary Data |
| 31 | + |
| 32 | +- For efficient document and file transfer, binary data is supported. |
| 33 | +- Use the `BinaryData` type for parameters or results that contain binary content. |
| 34 | +- Binary data is encoded as base64-encoded [MessagePack](https://msgpack.org/) in the `data` field of a `BinaryData` object. |
| 35 | + |
| 36 | +#### Example: Sending Binary Data |
| 37 | + |
| 38 | +```json |
| 39 | +{ |
| 40 | + "jsonrpc": "2.0", |
| 41 | + "id": 1, |
| 42 | + "method": "awareness/getDocumentContent", |
| 43 | + "params": ["path/to/file"] |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +The response will be: |
| 48 | + |
| 49 | +```json |
| 50 | +{ |
| 51 | + "jsonrpc": "2.0", |
| 52 | + "id": 1, |
| 53 | + "result": { |
| 54 | + "type": "binaryData", |
| 55 | + "data": "<base64-encoded-messagepack>" |
| 56 | + } |
| 57 | +} |
| 58 | +``` |
| 59 | + |
| 60 | +Or sending Binary Data as a Parameter: |
| 61 | + |
| 62 | +```json |
| 63 | +{ |
| 64 | + "jsonrpc": "2.0", |
| 65 | + "id": 2, |
| 66 | + "method": "fileSystem/writeFile", |
| 67 | + "params": [ |
| 68 | + { |
| 69 | + "type": "binaryData", |
| 70 | + "data": "<base64-encoded-messagepack>" |
| 71 | + } |
| 72 | + ] |
| 73 | +} |
| 74 | +``` |
0 commit comments