subs.js: fix a reconnection bug

Subscriptions would mistakenly report being closed due to a reversed
pair of connection state constants in the ws/sse switch, in isOpen().
This caused sockets to consider themselves open when they were, in fact,
closed.
This commit is contained in:
Kyle Kingsbury 2014-02-18 13:22:23 -08:00
parent a99da9bbdc
commit 1ceb9b5f4b

View file

@ -78,9 +78,9 @@ var subs = (function() {
isOpen: function() {
if (server_type == "ws") {
return this.ws && (this.ws.readyState != EventSource.CLOSED)
} else {
return this.ws && (this.ws.readyState != WebSocket.CLOSED)
} else {
return this.ws && (this.ws.readyState != EventSource.CLOSED)
}
},
isClosed: function() { return !this.isOpen() },
@ -99,6 +99,7 @@ var subs = (function() {
open: function() {
if (this.isOpen()) return this;
console.log("will open url: " + this.url());
var ws;