socket: Correctly reference the socket object inside event handlers

(imported from commit d5954007764f5e5e30b15d1af8e9b3c43a3ebde9)
This commit is contained in:
Zev Benjamin
2013-11-19 17:52:03 -05:00
parent d78511c933
commit 0ad0e18c49

View File

@@ -11,13 +11,14 @@ function Socket(url) {
this._reconnect_timeout_id = null;
this._heartbeat_timeout_id = null;
var that = this;
this._is_unloading = false;
$(window).on("unload", function () {
this._is_unloading = true;
that._is_unloading = true;
});
$(document).on("unsuspend", function () {
this._try_to_reconnect();
that._try_to_reconnect();
});
this._supported_protocols = ['websocket', 'xdr-streaming', 'xhr-streaming',