From 6e50ae94dd0cb8bc3302a3185cc8bdbec6012886 Mon Sep 17 00:00:00 2001 From: Yann Flory Date: Tue, 15 Mar 2016 10:51:19 +0100 Subject: [PATCH] Remove unused code --- www/common/netflux.js | 4 ++-- www/common/realtime-input.js | 31 +++---------------------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/www/common/netflux.js b/www/common/netflux.js index fa3680c16..68a90e386 100644 --- a/www/common/netflux.js +++ b/www/common/netflux.js @@ -258,11 +258,11 @@ return /******/ (function(modules) { // webpackBootstrap } }, { key: 'sendTo', - value: function sendTo(fromId, toId, msg) { + value: function sendTo(id, msg) { var channel = this; return new Promise(function (resolve, reject) { var protocol = _ServiceProvider2.default.get(channel.settings.protocol); - channel.topologyService.sendTo(toId, channel, protocol.message(cs.USER_DATA, { id: fromId, data: msg })).then(resolve, reject); + channel.topologyService.sendTo(id, channel, protocol.message(cs.USER_DATA, { id: channel.myID, data: msg })).then(resolve, reject); }); } }, { diff --git a/www/common/realtime-input.js b/www/common/realtime-input.js index 51e83d976..d5f3efef0 100644 --- a/www/common/realtime-input.js +++ b/www/common/realtime-input.js @@ -146,8 +146,7 @@ define([ var onPeerMessage = function(toId, type, wc) { if(type === 6) { messagesHistory.forEach(function(msg) { - var fromId = chainpadAdapter.historyOut('1:y'+msg) || wc.myID; - wc.sendTo(fromId, toId, '1:y'+msg); + wc.sendTo(toId, '1:y'+msg); }); } }; @@ -206,14 +205,8 @@ define([ }; chainpadAdapter = { - usernamesMapping : {}, msgIn : function(peerId, msg) { var parsed = parseMessage(msg); - if(parsed.content[0] === 0) { - if(peerId) { - this.usernamesMapping[peerId] = parsed.user; - } - } // Remove the password from the message var passLen = msg.substring(0,msg.indexOf(':')); var message = msg.substring(passLen.length+1 + Number(passLen)); @@ -228,35 +221,17 @@ define([ }, msgOut : function(msg, wc) { var parsed = parseMessage(msg); - if(parsed.content[0] === 0) { // Someone is registering + if(parsed.content[0] === 0) { // We're registering : send a REGISTER_ACK to Chainpad onMessage('', '1:y'+mkMessage('', channel, [1,0])); - // return msg; return; } - if(parsed.content[0] === 4) { // Someone is registering + if(parsed.content[0] === 4) { // PING message from Chainpad parsed.content[0] = 5; onMessage('', '1:y'+mkMessage(parsed.user, parsed.channelId, parsed.content)); wc.sendPing(); return; } return Crypto.encrypt(msg, cryptKey); - }, - leaving : function(peerId) { - if(this.usernamesMapping[peerId]) { - var chainpadUser = this.usernamesMapping[peerId]; - onMessage('', '1:y'+mkMessage(chainpadUser, channel, [3,0])); - } - }, - historyOut : function(msg) { - var parsed = parseMessage(msg); - if(parsed.content[0] === 0) { - var value = parsed.user; - var obj = this.usernamesMapping; - // Find the key (peerId) associated to the chainpad user in the map - var peerId = Object.keys(obj).filter(function(key) {return obj[key] === value;})[0]; - return peerId; - } - return; } };