Remove unused code

pull/1/head
Yann Flory 9 years ago
parent 5da8560e22
commit 6e50ae94dd

@ -258,11 +258,11 @@ return /******/ (function(modules) { // webpackBootstrap
} }
}, { }, {
key: 'sendTo', key: 'sendTo',
value: function sendTo(fromId, toId, msg) { value: function sendTo(id, msg) {
var channel = this; var channel = this;
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var protocol = _ServiceProvider2.default.get(channel.settings.protocol); 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);
}); });
} }
}, { }, {

@ -146,8 +146,7 @@ define([
var onPeerMessage = function(toId, type, wc) { var onPeerMessage = function(toId, type, wc) {
if(type === 6) { if(type === 6) {
messagesHistory.forEach(function(msg) { messagesHistory.forEach(function(msg) {
var fromId = chainpadAdapter.historyOut('1:y'+msg) || wc.myID; wc.sendTo(toId, '1:y'+msg);
wc.sendTo(fromId, toId, '1:y'+msg);
}); });
} }
}; };
@ -206,14 +205,8 @@ define([
}; };
chainpadAdapter = { chainpadAdapter = {
usernamesMapping : {},
msgIn : function(peerId, msg) { msgIn : function(peerId, msg) {
var parsed = parseMessage(msg); var parsed = parseMessage(msg);
if(parsed.content[0] === 0) {
if(peerId) {
this.usernamesMapping[peerId] = parsed.user;
}
}
// Remove the password from the message // Remove the password from the message
var passLen = msg.substring(0,msg.indexOf(':')); var passLen = msg.substring(0,msg.indexOf(':'));
var message = msg.substring(passLen.length+1 + Number(passLen)); var message = msg.substring(passLen.length+1 + Number(passLen));
@ -228,35 +221,17 @@ define([
}, },
msgOut : function(msg, wc) { msgOut : function(msg, wc) {
var parsed = parseMessage(msg); 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])); onMessage('', '1:y'+mkMessage('', channel, [1,0]));
// return msg;
return; return;
} }
if(parsed.content[0] === 4) { // Someone is registering if(parsed.content[0] === 4) { // PING message from Chainpad
parsed.content[0] = 5; parsed.content[0] = 5;
onMessage('', '1:y'+mkMessage(parsed.user, parsed.channelId, parsed.content)); onMessage('', '1:y'+mkMessage(parsed.user, parsed.channelId, parsed.content));
wc.sendPing(); wc.sendPing();
return; return;
} }
return Crypto.encrypt(msg, cryptKey); 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;
} }
}; };

Loading…
Cancel
Save