Improve the detection of a disconnected peer to update the user list with the WebRTC service

pull/1/head
Yann Flory 9 years ago
parent 77e7fb5724
commit 3a188625e0

@ -9,7 +9,6 @@ var run = module.exports.run = function(server) {
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) {
@ -33,7 +32,6 @@ var run = module.exports.run = function(server) {
socket.master = master
master.joiningClients.push(socket)
let id = master.joiningClients.length - 1
console.log(id);
master.send(JSON.stringify({id, data: msg.data}))
return
}

@ -222,9 +222,7 @@ return /******/ (function(modules) { // webpackBootstrap
_createClass(WebChannel, [{
key: 'leave',
value: function leave() {
this.topologyService.leave(this);
}
value: function leave() {}
}, {
key: 'send',
value: function send(data) {
@ -491,6 +489,7 @@ return /******/ (function(modules) { // webpackBootstrap
if (webChannel.channels.size === 0) {
webChannel.channels.add(channel);
channel.onclose = function () {
webChannel.onLeaving(channel.peerID);
webChannel.channels.delete(channel);
};
resolve(channel.peerID);
@ -522,6 +521,7 @@ return /******/ (function(modules) { // webpackBootstrap
var channel = webChannel.aboutToJoin.get(id);
webChannel.channels.add(webChannel.aboutToJoin.get(id));
channel.onclose = function () {
webChannel.onLeaving(channel.peerID);
webChannel.channels.delete(channel);
};
//webChannel.aboutToJoin.delete(id)
@ -602,8 +602,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'leave',
value: function leave(webChannel) {
var protocol = _ServiceProvider2.default.get(cs.EXCHANGEPROTOCOL_SERVICE);
this.broadcast(webChannel, protocol.message(cs.LEAVING, { id: webChannel.myID }));
this.broadcast(webChannel);
}
}, {
key: '_generateID',
@ -946,6 +945,10 @@ return /******/ (function(modules) { // webpackBootstrap
e.channel.webChannel = webChannel;
e.channel.onmessage = _this3.protocol.onmessage;
webChannel.channels.add(e.channel);
e.channel.onclose = function () {
webChannel.onLeaving(e.channel.peerID);
webChannel.channels.delete(e.channel);
};
};
};
connection.onicecandidate = function (e) {
@ -1158,9 +1161,6 @@ return /******/ (function(modules) { // webpackBootstrap
case cs.GET_HISTORY:
webChannel.onPeerMessage(msg.id, msg.code);
break;
case cs.LEAVING:
webChannel.onLeaving(msg.id);
break;
case cs.SERVICE_DATA:
var service = _ServiceProvider2.default.get(msg.service);
service.onmessage(channel, msg.data);
@ -1178,7 +1178,6 @@ return /******/ (function(modules) { // webpackBootstrap
case cs.JOIN_FINISH:
webChannel.topologyService.addFinish(webChannel, msg.id);
if (msg.id != webChannel.myID) {
console.log('different id');
webChannel.onJoining(msg.id);
}
break;
@ -1196,9 +1195,6 @@ return /******/ (function(modules) { // webpackBootstrap
case cs.GET_HISTORY:
msg.id = data.id;
break;
case cs.LEAVING:
msg.id = data.id;
break;
case cs.SERVICE_DATA:
msg.service = data.service;
msg.data = Object.assign({}, data.data);

@ -281,10 +281,6 @@ define([
onPeerMessage(peerId, type, wc);
};
window.onunload = function() {
wc.leave();
};
// Open a Chainpad session
realtime = createRealtime();

Loading…
Cancel
Save