mirror of
https://github.com/jech/galene.git
synced 2024-12-22 15:25:48 +01:00
Don't set group if joining failed.
We used to set sc.group even if joining failed, which would cause us to spuriously call the onJoined callback when we disconnected.
This commit is contained in:
parent
cba04e7de5
commit
59ff25310d
1 changed files with 15 additions and 11 deletions
|
@ -368,22 +368,26 @@ ServerConnection.prototype.connect = async function(url) {
|
|||
sc.gotRemoteIce(m.id, m.candidate);
|
||||
break;
|
||||
case 'joined':
|
||||
if(sc.group) {
|
||||
if(m.group !== sc.group) {
|
||||
throw new Error('Joined multiple groups');
|
||||
}
|
||||
} else {
|
||||
sc.group = m.group;
|
||||
}
|
||||
sc.username = m.username;
|
||||
sc.permissions = m.permissions || [];
|
||||
sc.rtcConfiguration = m.rtcConfiguration || null;
|
||||
if(m.kind == 'leave') {
|
||||
if(m.kind === 'leave' || m.kind === 'fail') {
|
||||
for(let id in sc.users) {
|
||||
delete(sc.users[id]);
|
||||
if(sc.onuser)
|
||||
sc.onuser.call(sc, id, 'delete');
|
||||
}
|
||||
sc.username = null;
|
||||
sc.permissions = [];
|
||||
sc.rtcConfiguration = null;
|
||||
} else if(m.kind === 'join' || m.kind == 'change') {
|
||||
if(m.kind === 'join' && sc.group) {
|
||||
throw new Error('Joined multiple groups');
|
||||
} else if(m.kind === 'change' && m.group != sc.group) {
|
||||
console.warn('join(change) for inconsistent group');
|
||||
break;
|
||||
}
|
||||
sc.group = m.group;
|
||||
sc.username = m.username;
|
||||
sc.permissions = m.permissions || [];
|
||||
sc.rtcConfiguration = m.rtcConfiguration || null;
|
||||
}
|
||||
if(sc.onjoined)
|
||||
sc.onjoined.call(sc, m.kind, m.group,
|
||||
|
|
Loading…
Reference in a new issue