1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-16 10:06:54 +00:00

client: Move room/channel distinction into name (room.trihex)

Also, have the client send a "ready" message when it has sent all its
initial requests.
This commit is contained in:
Kane York 2015-10-26 12:13:28 -07:00
parent 69676bf287
commit 85d261afb3
10 changed files with 62 additions and 162 deletions

View file

@ -153,10 +153,10 @@ FFZ.prototype.setup_channel = function() {
if ( id !== f.__old_host_target ) {
if ( f.__old_host_target )
f.ws_send("unsub_channel", f.__old_host_target);
f.ws_send("unsub", "channel." + f.__old_host_target);
if ( id ) {
f.ws_send("sub_channel", id);
f.ws_send("sub", "channel." + id);
f.__old_host_target = id;
} else
delete f.__old_host_target;
@ -208,7 +208,7 @@ FFZ.prototype._modify_cindex = function(view) {
el = this.get('element');
f._cindex = this;
f.ws_send("sub_channel", id);
f.ws_send("sub", "channel." + id);
el.setAttribute('data-channel', id);
el.classList.add('ffz-channel');
@ -621,7 +621,7 @@ FFZ.prototype._modify_cindex = function(view) {
ffzTeardown: function() {
var id = this.get('controller.id');
if ( id )
f.ws_send("unsub_channel", id);
f.ws_send("unsub", "channel." + id);
this.get('element').setAttribute('data-channel', '');
f._cindex = undefined;

View file

@ -591,7 +591,7 @@ FFZ.prototype.add_room = function(id, room) {
}
// Let the server know where we are.
this.ws_send("sub", id);
this.ws_send("sub", "room." + id);
// See if we need history?
if ( ! this.has_bttv && this.settings.chat_history && room && (room.get('messages.length') || 0) < 10 ) {
@ -619,7 +619,7 @@ FFZ.prototype.remove_room = function(id) {
utils.update_css(this._room_style, id, null);
// Let the server know we're gone and delete our data for this room.
this.ws_send("unsub", id);
this.ws_send("unsub", "room." + id);
delete this.rooms[id];
// Clean up sets we aren't using any longer.

View file

@ -64,8 +64,8 @@ FFZ.prototype.ws_create = function() {
if ( f.is_dashboard ) {
var match = location.pathname.match(/\/([^\/]+)/);
if ( match ) {
f.ws_send("sub", match[1]);
f.ws_send("sub_channel", match[1]);
f.ws_send("sub", "room." + match[1]);
f.ws_send("sub", "channel." + match[1]);
}
}
@ -74,7 +74,7 @@ FFZ.prototype.ws_create = function() {
if ( ! f.rooms.hasOwnProperty(room_id) || ! f.rooms[room_id] )
continue;
f.ws_send("sub", room_id);
f.ws_send("sub", "room." + room_id);
if ( f.rooms[room_id].needs_history ) {
f.rooms[room_id].needs_history = false;
@ -89,10 +89,10 @@ FFZ.prototype.ws_create = function() {
hosted_id = f._cindex.get('controller.hostModeTarget.id');
if ( channel_id )
f.ws_send("sub_channel", channel_id);
f.ws_send("sub", "channel." + channel_id);
if ( hosted_id )
f.ws_send("sub_channel", hosted_id);
f.ws_send("sub", "channel." + hosted_id);
}
// Send any pending commands.
@ -103,11 +103,32 @@ FFZ.prototype.ws_create = function() {
var d = pending[i];
f.ws_send(d[0], d[1], d[2]);
}
// If reconnecting, get the backlog that we missed.
if ( f._ws_offline_time ) {
var timestamp = f._ws_offline_time;
delete f._ws_offline_time;
f.ws_send("ready", timestamp);
} else {
f.ws_send("ready", 0);
}
}
ws.onerror = function() {
if ( ! f._ws_offline_time ) {
f._ws_offline_time = new Date().getTime();
}
// Cycle selected server
f._ws_host_idx = (f._ws_host_idx + 1) % constants.WS_SERVERS.length;
}
ws.onclose = function(e) {
f.log("Socket closed. (Code: " + e.code + ", Reason: " + e.reason + ")");
f._ws_open = false;
if ( ! f._ws_offline_time ) {
f._ws_offline_time = new Date().getTime();
}
// When the connection closes, run our callbacks.
for (var i=0; i < FFZ.ws_on_close.length; i++) {
@ -118,7 +139,7 @@ FFZ.prototype.ws_create = function() {
}
}
// Attempt to cycle to backup server
// Cycle selected server
f._ws_host_idx = (f._ws_host_idx + 1) % constants.WS_SERVERS.length;
if ( f._ws_delay > 10000 ) {