Rooms can now expire

Rooms send |expire| when they expire; this means that the room no
longer exists server-side but the client might want to leave the room
open.
This commit is contained in:
Guangcong Luo 2013-09-29 22:52:40 -05:00
parent 89aeb2ecaa
commit d03bea97af
2 changed files with 17 additions and 1 deletions

View File

@ -23,7 +23,10 @@
updateUser: function() {
var name = app.user.get('name');
var userid = app.user.get('userid');
if (!name) {
if (this.expired) {
this.$chatAdd.html('This room is expired');
this.$chatbox = null;
} else if (!name) {
this.$chatAdd.html('Connecting...');
this.$chatbox = null;
} else if (!app.user.get('named')) {

View File

@ -782,8 +782,21 @@
} else {
this.joinRoom(roomid, roomType, true);
}
} else if ((data+'|').substr(0,8) === '|expire|') {
var room = this.rooms[roomid];
if (room) {
room.expired = true;
if (room.updateUser) room.updateUser();
}
return;
} else if ((data+'|').substr(0,8) === '|deinit|' || (data+'|').substr(0,8) === '|noinit|') {
if (!roomid) roomid = 'lobby';
if (this.rooms[roomid] && this.rooms[roomid].expired) {
// expired rooms aren't closed when left
return;
}
var isdeinit = (data.charAt(1) === 'd');
data = data.substr(8);
var pipeIndex = data.indexOf('|');