1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00

Fixed some hard-coded HTTP protocols. Moved betterttv into ext/ folder. Added support for Emote Menu for Twitch. Added support for non-critical WebSocket calls that wait till the socket is connected.

This commit is contained in:
SirStendec 2015-01-19 15:27:10 -05:00
parent 2c3af2d51e
commit 3d3c1f9716
12 changed files with 434 additions and 233 deletions

View file

@ -15,6 +15,7 @@ FFZ.prototype.ws_create = function() {
this._ws_last_req = 0;
this._ws_callbacks = {};
this._ws_pending = this._ws_pending || [];
var ws = this._ws_sock = new WebSocket("ws://ffz.stendec.me/");
@ -30,6 +31,15 @@ FFZ.prototype.ws_create = function() {
// Send the current rooms.
for(var room_id in f.rooms)
f.ws_send("sub", room_id);
// Send any pending commands.
var pending = f._ws_pending;
f._ws_pending = [];
for(var i=0; i < pending.length; i++) {
var d = pending[i];
f.ws_send(d[0], d[1], d[2]);
}
}
ws.onclose = function(e) {
@ -79,8 +89,15 @@ FFZ.prototype.ws_create = function() {
}
FFZ.prototype.ws_send = function(func, data, callback) {
if ( ! this._ws_open ) return false;
FFZ.prototype.ws_send = function(func, data, callback, can_wait) {
if ( ! this._ws_open ) {
if ( can_wait ) {
var pending = this._ws_pending = this._ws_pending || [];
pending.push([func, data, callback]);
return true;
} else
return false;
}
var request = ++this._ws_last_req;
data = data !== undefined ? " " + JSON.stringify(data) : "";