From 968e71e038f436948cbd817d9c19f63f42934ed7 Mon Sep 17 00:00:00 2001 From: Mansehej Singh Date: Sun, 12 Jul 2020 21:11:42 +0530 Subject: [PATCH] Update ReadMe for HTTP Callbacks --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 0e61288..bc12eea 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,22 @@ See [LevelDB Persistence](https://github.com/yjs/y-leveldb) for more info. PORT=1234 YPERSISTENCE=./dbDir node ./node_modules/y-websocket/bin/server.js ``` +**Websocket Server with HTTP callback** + +Send a debounced callback to an HTTP server (POST) on document update. + +Can take the following ENV variables: +- CALLBACK_URL : Callback server URL. +- CALLBACK_DEBOUNCE_WAIT : Debounce time between callbacks. Defaults to 2 seconds. +- CALLBACK_DEBOUNCE_MAXWAIT : Maximum time to wait before callback. Defaults to 10 seconds. +- CALLBACK_TIMEOUT : Timeout for the HTTP call. Defaults to 5 seconds. +- CALLBACK_OBJECTS : JSON of shared objects to get data. ('{"SHARED_OBJECT_NAME":"SHARED_OBJECT_TYPE}') + +```sh +CALLBACK_URL=http://localhost:3000/ CALLBACK_OBJECTS='{"prosemirror":"XmlFragment"}' node ./node_modules/y-websocket/bin/server.js +``` +This would send a callback to localhost:3000 every 2 seconds (default DEBOUNCE_WAIT) with the data of an XmlFragment named Prosemirror in the body. + ### Scaling These are mere suggestions how you could scale your server environment.