Fix an issue with the WebRTC service where it was impossible to join a channel once someone had left this channel

pull/1/head
Yann Flory 9 years ago
parent 06e5c84702
commit 77e7fb5724

@ -49,7 +49,6 @@ var popPassword = function (msg) {
}; };
var sendMsg = function (msg, socket) { var sendMsg = function (msg, socket) {
console.log('>> '+msg);
socket.send(msg); socket.send(msg);
}; };
@ -109,7 +108,6 @@ var dropClient = function (ctx, userpass) {
}; };
var handleMessage = function (ctx, socket, msg) { var handleMessage = function (ctx, socket, msg) {
console.log('<< '+msg);
var parsed = parseMessage(msg); var parsed = parseMessage(msg);
var userPass = parsed.user + ':' + parsed.pass; var userPass = parsed.user + ':' + parsed.pass;
msg = popPassword(msg); msg = popPassword(msg);

@ -9,6 +9,7 @@ var run = module.exports.run = function(server) {
socket.on('message', (data) => { socket.on('message', (data) => {
try { try {
let msg = JSON.parse(data) let msg = JSON.parse(data)
console.log(msg);
if (msg.hasOwnProperty('key')) { if (msg.hasOwnProperty('key')) {
for (let master of server.clients) { for (let master of server.clients) {
if (master.key === msg.key) { if (master.key === msg.key) {
@ -32,6 +33,7 @@ var run = module.exports.run = function(server) {
socket.master = master socket.master = master
master.joiningClients.push(socket) master.joiningClients.push(socket)
let id = master.joiningClients.length - 1 let id = master.joiningClients.length - 1
console.log(id);
master.send(JSON.stringify({id, data: msg.data})) master.send(JSON.stringify({id, data: msg.data}))
return return
} }

@ -406,7 +406,7 @@ return /******/ (function(modules) { // webpackBootstrap
value: function get(code) { value: function get(code) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var service = void 0; var service = undefined;
switch (code) { switch (code) {
case cs.WEBRTC_SERVICE: case cs.WEBRTC_SERVICE:
service = new _WebRTCService2.default(options); service = new _WebRTCService2.default(options);
@ -490,6 +490,9 @@ return /******/ (function(modules) { // webpackBootstrap
if (webChannel.channels.size === 0) { if (webChannel.channels.size === 0) {
webChannel.channels.add(channel); webChannel.channels.add(channel);
channel.onclose = function () {
webChannel.channels.delete(channel);
};
resolve(channel.peerID); resolve(channel.peerID);
} else { } else {
(function () { (function () {
@ -515,11 +518,17 @@ return /******/ (function(modules) { // webpackBootstrap
key: 'addFinish', key: 'addFinish',
value: function addFinish(webChannel, id) { value: function addFinish(webChannel, id) {
if (id != webChannel.myID) { if (id != webChannel.myID) {
webChannel.channels.add(webChannel.aboutToJoin.get(id)); (function () {
//webChannel.aboutToJoin.delete(id) var channel = webChannel.aboutToJoin.get(id);
if (Reflect.has(webChannel, 'successfullyConnected')) { webChannel.channels.add(webChannel.aboutToJoin.get(id));
webChannel.successfullyConnected.delete(id); channel.onclose = function () {
} webChannel.channels.delete(channel);
};
//webChannel.aboutToJoin.delete(id)
if (Reflect.has(webChannel, 'successfullyConnected')) {
webChannel.successfullyConnected.delete(id);
}
})();
} else { } else {
webChannel.onopen(); webChannel.onopen();
} }
@ -846,7 +855,7 @@ return /******/ (function(modules) { // webpackBootstrap
var settings = Object.assign({}, this.settings, options); var settings = Object.assign({}, this.settings, options);
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var connection = void 0; var connection = undefined;
var socket = new window.WebSocket(settings.signaling); var socket = new window.WebSocket(settings.signaling);
socket.onopen = function () { socket.onopen = function () {
connection = new _this2.RTCPeerConnection(settings.webRTCOptions); connection = new _this2.RTCPeerConnection(settings.webRTCOptions);
@ -966,8 +975,8 @@ return /******/ (function(modules) { // webpackBootstrap
}, function () {}); }, function () {});
})(); })();
} else if (msg.sdp.type === 'answer') { } else if (msg.sdp.type === 'answer') {
var _sd = Object.assign(new this.RTCSessionDescription(), msg.sdp); var sd = Object.assign(new this.RTCSessionDescription(), msg.sdp);
webChannel.connections.get(msg.senderPeerID).setRemoteDescription(_sd, function () {}, function () {}); webChannel.connections.get(msg.senderPeerID).setRemoteDescription(sd, function () {}, function () {});
} }
} else if (Reflect.has(msg, 'candidate')) { } else if (Reflect.has(msg, 'candidate')) {
webChannel.connections.get(msg.senderPeerID).addIceCandidate(new this.RTCIceCandidate(msg.candidate)); webChannel.connections.get(msg.senderPeerID).addIceCandidate(new this.RTCIceCandidate(msg.candidate));
@ -1080,7 +1089,7 @@ return /******/ (function(modules) { // webpackBootstrap
var settings = Object.assign({}, this.settings, options); var settings = Object.assign({}, this.settings, options);
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
var connection = void 0; var connection = undefined;
var socket = new window.WebSocket(settings.signaling); var socket = new window.WebSocket(settings.signaling);
socket.seq = 1; socket.seq = 1;
socket.facade = options.facade || null; socket.facade = options.facade || null;
@ -1169,6 +1178,7 @@ return /******/ (function(modules) { // webpackBootstrap
case cs.JOIN_FINISH: case cs.JOIN_FINISH:
webChannel.topologyService.addFinish(webChannel, msg.id); webChannel.topologyService.addFinish(webChannel, msg.id);
if (msg.id != webChannel.myID) { if (msg.id != webChannel.myID) {
console.log('different id');
webChannel.onJoining(msg.id); webChannel.onJoining(msg.id);
} }
break; break;
@ -1321,7 +1331,7 @@ return /******/ (function(modules) { // webpackBootstrap
}, { }, {
key: 'message', key: 'message',
value: function message(code, data) { value: function message(code, data) {
var type = void 0; var type = undefined;
switch (code) { switch (code) {
case cs.USER_DATA: case cs.USER_DATA:
type = 'MSG'; type = 'MSG';

@ -363,7 +363,6 @@ define([
else { warn(error); } else { warn(error); }
}); });
}; };
joinChannel(); joinChannel();
var checkConnection = function(wc) { var checkConnection = function(wc) {

Loading…
Cancel
Save