y-websockets-server

所属分类:Websocket编程
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2023-01-11 11:19:08
上 传 者sh-1993
说明:  Yjs的Websocket连接器(节点服务器)
(Websocket connector for Yjs (Node server))

文件列表:
Dockerfile (84, 2021-02-18)
Procfile (15, 2021-02-18)
package-lock.json (65755, 2021-02-18)
package.json (1019, 2021-02-18)
src/ (0, 2021-02-18)
src/server.js (3677, 2021-02-18)
src/y-websockets-server.js (1399, 2021-02-18)

# (LEGACY) Websockets Connector for [Yjs](https://github.com/y-js/yjs) (Server) > Note: this is an outdated repository which is not compatible with y-websocket or Yjs>=v13 *y-websockets-server* is the connection point for *y-websockets-client*. It saves the shared data (using the [memory](https://github.com/y-js/y-memory) or the [leveldb](https://github.com/y-js/y-leveldb) database adapter), and distributes it efficiently to all connected clients. #### Instructions for [y-leveldb](https://github.com/y-js/y-leveldb) The memory database adapter is installed by default. If you intend to use the [y-leveldb](https://github.com/y-js/y-leveldb) database adapter, make sure to install it first. ```sh npm install --save y-leveldb [-g] ``` ### Global installation (easy) * Install package `npm install -g y-websockets-server` * Execute binary `y-websockets-server [--port port] [--db db]` (defaults: port = 1234, db = `memory` (choose either `leveldb` or `memory`)). Yjs uses [debug](https://github.com/visionmedia/debug) for logging. In order to turn on logging set the environment variable `DEBUG` to `y*,-y:connector-message`: I.e ```sh DEBUG=y*,-y:connector-message y-websockets-server --port 1234 ``` This is how you redirect the output to a file: ```sh DEBUG_COLORS=0 DEBUG=y*,-y:connector-message y-websockets-server --port 1234 > log.txt ``` ### Local installation (recommended if you intend to modify y-websockets-server) * Set up a new project mkdir my-y-websockets-server && cd $_ && git init && npm init && echo "node_modules" > .gitignore * Install `npm i --save y-websockets-server` * Copy executable `cp node_modules/y-websockets-server/src/server.js .` * Start server `node server.js` ### Setup with Docker * Clone this repository and navigate to it. * Build the image: `docker build -t y-websockets-server .` * Run it: `docker run -it --rm -p 1234:1234 --name y-websockets-server y-websockets-server` * Feel free to modify the port argument, e.g. to `-p 1773:1234` to run it at port 1773. ### Setup with Heroku Heroku is really easy to set up, and you get a free *y-websockets-server* with https! Preliminarily you have to set up heroku - see this great [getting started guide](https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction) * Perform the steps from the local installation * Create Procfile `echo "web: DEBUG=y*,-y:connector-message server.js" > Procfile` * Specify a node environment. Add this to your package.json: "engines": { "node": "6.9.1" } * Add heroku app `heroku create my-websockets-server` * Commit & Push to heroku `git add -A && git commit -am 'init' && git push heroku master` * Start app `heroku ps:scale web=1` * Get the url for your websockes-server instance `heroku info` (see *Web Url*).

近期下载者

相关文件


收藏者