diff --git a/WebRTCSrv.js b/WebRTCSrv.js deleted file mode 100644 index 2c1bc81e2..000000000 --- a/WebRTCSrv.js +++ /dev/null @@ -1,61 +0,0 @@ -'use strict' -let WebSocketServer = require('ws').Server -const UNSUPPORTED_DATA = 1007 -const POLICY_VIOLATION = 1008 -const CLOSE_UNSUPPORTED = 1003 - -var run = module.exports.run = function(server) { - server.on('connection', (socket) => { - if(socket.upgradeReq.url !== '/cryptpad_webrtc') { return; } - socket.on('message', (data) => { - try { - let msg = JSON.parse(data) - console.log(msg) - if (msg.hasOwnProperty('key')) { - for (let master of server.clients) { - if (master.key === msg.key) { - socket.close(POLICY_VIOLATION, 'The key already exists') - return - } - } - socket.key = msg.key - socket.joiningClients = [] - } else if (msg.hasOwnProperty('id')) { - for (let index in socket.joiningClients) { - if (index == msg.id) { - socket.joiningClients[index].send(JSON.stringify({data: msg.data})) - return - } - } - socket.close(POLICY_VIOLATION, 'Unknown id') - } else if (msg.hasOwnProperty('join')) { - for (let master of server.clients) { - if (master.key === msg.join) { - socket.master = master - master.joiningClients.push(socket) - let id = master.joiningClients.length - 1 - master.send(JSON.stringify({id, data: msg.data})) - return - } - } - socket.close(POLICY_VIOLATION, 'Unknown key') - } else if (msg.hasOwnProperty('data') && socket.hasOwnProperty('master')) { - let id = socket.master.joiningClients.indexOf(socket) - socket.master.send(JSON.stringify({id, data: msg.data})) - } else { - socket.close(UNSUPPORTED_DATA, 'Unsupported message format') - } - } catch (event) { - socket.close(CLOSE_UNSUPPORTED, 'Server accepts only JSON') - } - }) - - socket.on('close', (event) => { - if (socket.hasOwnProperty('joiningClients')) { - for (let client of socket.joiningClients) { - client.close(POLICY_VIOLATION, 'The peer is no longer available') - } - } - }); - }) -} \ No newline at end of file diff --git a/server.js b/server.js index e23f9bcb4..2be619e48 100644 --- a/server.js +++ b/server.js @@ -7,7 +7,6 @@ var Https = require('https'); var Fs = require('fs'); var WebSocketServer = require('ws').Server; var NetfluxSrv = require('./NetfluxWebsocketSrv'); -var WebRTCSrv = require('./WebRTCSrv'); var config = require('./config'); var websocketPort = config.websocketPort || config.httpPort; @@ -103,5 +102,4 @@ if (websocketPort !== config.httpPort) { var wsSrv = new WebSocketServer(wsConfig); Storage.create(config, function (store) { NetfluxSrv.run(store, wsSrv, config); - WebRTCSrv.run(wsSrv); }); diff --git a/www/canvas/index.html b/www/examples/canvas/index.html similarity index 100% rename from www/canvas/index.html rename to www/examples/canvas/index.html diff --git a/www/canvas/main.js b/www/examples/canvas/main.js similarity index 99% rename from www/canvas/main.js rename to www/examples/canvas/main.js index cf26d063c..114424c18 100644 --- a/www/canvas/main.js +++ b/www/examples/canvas/main.js @@ -13,7 +13,7 @@ define([ '/bower_components/fabric.js/dist/fabric.min.js', '/bower_components/jquery/dist/jquery.min.js', '/bower_components/file-saver/FileSaver.min.js', - '/customize/pad.js' + //'/customize/pad.js' ], function (Config, Realtime, Crypto, TextPatcher, JSONSortify, JsonOT, Cryptpad) { var saveAs = window.saveAs;