[Pkg-javascript-commits] [sockjs-client] 102/434: Move EventSource transport to the generic polling infrastructure.
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:07 UTC 2014
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch master
in repository sockjs-client.
commit 71c5aa229d2822744ab9860ad2a9d042308eb34e
Author: Marek Majkowski <majek04 at gmail.com>
Date: Thu Aug 25 15:39:35 2011 +0100
Move EventSource transport to the generic polling infrastructure.
---
lib/trans-iframe-eventsource.js | 18 +++++-------------
lib/trans-receiver-eventsource.js | 4 ++--
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/lib/trans-iframe-eventsource.js b/lib/trans-iframe-eventsource.js
index 762b806..7296a60 100644
--- a/lib/trans-iframe-eventsource.js
+++ b/lib/trans-iframe-eventsource.js
@@ -16,15 +16,8 @@ var EventSourceTransport = FacadeJS['w-iframe-eventsource'] = function (ri, tran
var that = this;
that.ri = ri;
that.trans_url = trans_url;
- var url = trans_url + '/eventsource';
- var es = that.es = new EventSource(url);
- es.onmessage = function(e) {that.ri._didMessage(unescape(e.data));};
- es.onerror = function(e) {
- // EventSource reconnects automatically.
- es.close();
- that.ri._didClose(1001, "Socket closed.");
- };
that.send_constructor(ajaxSender);
+ that.poll = new Polling(ri, EventSourceReceiver, trans_url + '/eventsource');
};
// Inheritnace
@@ -32,11 +25,10 @@ EventSourceTransport.prototype = new BufferedSender();
EventSourceTransport.prototype.doCleanup = function() {
var that = this;
- var es = that.es;
- es.onmessage = es.onerror = null;
- es.close();
- that.send_destructor();
- that.es = that.ri = null;
+ if (that.poll) {
+ that.poll.abort();
+ that.poll = null;
+ }
};
diff --git a/lib/trans-receiver-eventsource.js b/lib/trans-receiver-eventsource.js
index 16e4087..add475e 100644
--- a/lib/trans-receiver-eventsource.js
+++ b/lib/trans-receiver-eventsource.js
@@ -7,10 +7,10 @@ var EventSourceReceiver = function(url) {
{'data': unescape(e.data)}));
};
that.es_close = es.onerror = function(e, abort_reason) {
- // ES on reconnection has readyState = OPEN = 1.
+ // ES on reconnection has readyState = 0 or 1.
// on network error it's CLOSED = 2
var reason = abort_reason ? 'user' :
- (es.readyState === 1 ? 'network' : 'permanent');
+ (es.readyState !== 2 ? 'network' : 'permanent');
that.es_close = es.onmessage = es.onerror = null;
// EventSource reconnects automatically.
es.close();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list