Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/externals/javelin/lib/Websocket.js
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | members: { | ||||
* Open the connection. | * Open the connection. | ||||
*/ | */ | ||||
open: function() { | open: function() { | ||||
if (!window.WebSocket) { | if (!window.WebSocket) { | ||||
return; | return; | ||||
} | } | ||||
this._shouldClose = false; | this._shouldClose = false; | ||||
this._resetDelay(); | |||||
this._socket = new WebSocket(this.getURI()); | this._socket = new WebSocket(this.getURI()); | ||||
this._socket.onopen = JX.bind(this, this._onopen); | this._socket.onopen = JX.bind(this, this._onopen); | ||||
this._socket.onmessage = JX.bind(this, this._onmessage); | this._socket.onmessage = JX.bind(this, this._onmessage); | ||||
this._socket.onclose = JX.bind(this, this._onclose); | this._socket.onclose = JX.bind(this, this._onclose); | ||||
}, | }, | ||||
Show All 24 Lines | members: { | ||||
/** | /** | ||||
* Callback for connection open. | * Callback for connection open. | ||||
*/ | */ | ||||
_onopen: function(e) { | _onopen: function(e) { | ||||
this._isOpen = true; | this._isOpen = true; | ||||
// Reset the reconnect delay, since we connected successfully. | // Reset the reconnect delay, since we connected successfully. | ||||
this._delayUntilReconnect = 2000; | this._resetDelay(); | ||||
var handler = this.getOpenHandler(); | var handler = this.getOpenHandler(); | ||||
if (handler) { | if (handler) { | ||||
handler(); | handler(); | ||||
} | } | ||||
}, | }, | ||||
/** | /** | ||||
* Reset the reconnect delay to its base value. | |||||
*/ | |||||
_resetDelay: function() { | |||||
this._delayUntilReconnect = 2000; | |||||
}, | |||||
epriestley: Fixes a bug where we didn't set the delay properly. | |||||
/** | |||||
* Callback for message received. | * Callback for message received. | ||||
*/ | */ | ||||
_onmessage: function(e) { | _onmessage: function(e) { | ||||
var data = e.data; | var data = e.data; | ||||
var handler = this.getMessageHandler(); | var handler = this.getMessageHandler(); | ||||
if (handler) { | if (handler) { | ||||
handler(data); | handler(data); | ||||
Show All 39 Lines |
Fixes a bug where we didn't set the delay properly.