Don't rejoin a dropped channel on reconnect and leave chat channel

This commit is contained in:
yflory
2018-10-04 15:29:34 +02:00
parent 2a86db2001
commit 498703384f
3 changed files with 40 additions and 6 deletions

View File

@@ -985,7 +985,7 @@ define([
/////////////////////// PAD //////////////////////////////////////
//////////////////////////////////////////////////////////////////
var channels = Store.channels = {};
var channels = Store.channels = store.channels = {};
Store.joinPad = function (clientId, data) {
var isNew = typeof channels[data.channel] === "undefined";
@@ -1093,12 +1093,12 @@ define([
});
}
};
CpNfWorker.start(conf);
channel.cpNf = CpNfWorker.start(conf);
};
Store.leavePad = function (clientId, data, cb) {
var channel = channels[data.channel];
if (!channel || !channel.wc) { return void cb ({error: 'EINVAL'}); }
channel.wc.leave();
if (!channel || !channel.cpNf) { return void cb ({error: 'EINVAL'}); }
channel.cpNf.stop();
delete channels[data.channel];
cb();
};
@@ -1278,9 +1278,12 @@ define([
var dropChannel = function (chanId) {
if (!Store.channels[chanId]) { return; }
if (Store.channels[chanId].wc) {
Store.channels[chanId].wc.leave('');
if (Store.channels[chanId].cpNf) {
Store.channels[chanId].cpNf.stop();
}
store.messenger.leavePad(chanId);
delete Store.channels[chanId];
};
Store._removeClient = function (clientId) {