From 9195c5744549fab0104fa844f5581ff0c7a7f755 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 4 Jun 2018 14:59:37 +0200 Subject: [PATCH] Use socket.io instead of WebSocket --- package.json | 1 + server.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7ad861062..06214aab8 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "pull-stream": "^3.6.1", "replify": "^1.2.0", "saferphore": "0.0.1", + "socket.io": "^2.1.1", "sortify": "^1.0.4", "stream-to-pull-stream": "^1.7.2", "tweetnacl": "~0.12.2", diff --git a/server.js b/server.js index aac8d7513..feddc8bbe 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,7 @@ var Express = require('express'); var Http = require('http'); var Https = require('https'); var Fs = require('fs'); -var WebSocketServer = require('ws').Server; +var SocketIO = require('socket.io'); var NetfluxSrv = require('./node_modules/chainpad-server/NetfluxWebsocketSrv'); var Package = require('./package.json'); var Path = require("path"); @@ -246,7 +246,10 @@ var nt = nThen(function (w) { console.log("setting up a new websocket server"); wsConfig = { port: websocketPort}; } - var wsSrv = new WebSocketServer(wsConfig); + var wsSrv = new SocketIO(httpServer, { + path: config.websocketPath || '/cryptpad_websocket' + }); + Storage.create(config, function (store) { NetfluxSrv.run(store, wsSrv, config, rpc); });