[Pkg-javascript-commits] [sockjs-client] 103/434: New transport: xhr-streaming, it will duplicate functionality of xhr-polling for a moment.
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 296b2bf1c162e71da492dcd48dfb803316550a6c
Author: Marek Majkowski <majek04 at gmail.com>
Date: Thu Aug 25 16:37:46 2011 +0100
New transport: xhr-streaming, it will duplicate functionality of xhr-polling for a moment.
---
lib/index.js | 1 +
lib/sockjs.js | 1 +
lib/trans-iframe-eventsource.js | 2 --
lib/trans-xhr-streaming.js | 29 +++++++++++++++++++++++++++++
tests/html/src/tests.coffee | 1 +
5 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/lib/index.js b/lib/index.js
index d61dfae..1778a80 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -11,6 +11,7 @@ SockJS = (function(){
<!-- include lib/trans-jsonp-receiver.js -->
<!-- include lib/trans-jsonp-polling.js -->
<!-- include lib/trans-xhr-polling.js -->
+<!-- include lib/trans-xhr-streaming.js -->
<!-- include lib/trans-iframe.js -->
<!-- include lib/trans-iframe-within.js -->
<!-- include lib/trans-iframe-eventsource.js -->
diff --git a/lib/sockjs.js b/lib/sockjs.js
index 20ac833..dd8bc79 100644
--- a/lib/sockjs.js
+++ b/lib/sockjs.js
@@ -9,6 +9,7 @@ var SockJS = function(url, protocols, options) {
that._connid = utils.random_string(8);
that._trans_url = that._base_url + '/' + that._server + '/' + that._connid;
that._protocols = ['websocket',
+ 'xhr-streaming',
'iframe-eventsource',
'iframe-htmlfile',
'xhr-polling',
diff --git a/lib/trans-iframe-eventsource.js b/lib/trans-iframe-eventsource.js
index 7296a60..bc6073e 100644
--- a/lib/trans-iframe-eventsource.js
+++ b/lib/trans-iframe-eventsource.js
@@ -30,5 +30,3 @@ EventSourceTransport.prototype.doCleanup = function() {
that.poll = null;
}
};
-
-
diff --git a/lib/trans-xhr-streaming.js b/lib/trans-xhr-streaming.js
new file mode 100644
index 0000000..c38db7b
--- /dev/null
+++ b/lib/trans-xhr-streaming.js
@@ -0,0 +1,29 @@
+var XhrStreamingTransport = SockJS['xhr-streaming'] = function (ri, trans_url) {
+ var that = this;
+ that.ri = ri;
+ that.trans_url = trans_url;
+ that.send_constructor(xdrSender);
+ that.poll = new Polling(ri, XhrCorsReceiver, trans_url + '/xhr_streaming');
+};
+
+// Inheritnace
+XhrStreamingTransport.prototype = new BufferedSender();
+
+XhrStreamingTransport.prototype.doCleanup = function() {
+ var that = this;
+ if (that.poll) {
+ that.poll.abort();
+ that.poll = null;
+ }
+};
+
+// According to:
+// http://stackoverflow.com/questions/1641507/detect-browser-support-for-cross-domain-xmlhttprequests
+// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
+XhrStreamingTransport.enabled = function(options) {
+ if (!options.cookie && window.XDomainRequest) return true;
+ if (window.XMLHttpRequest &&
+ 'withCredentials' in new XMLHttpRequest()) return true;
+ return false;
+};
+
diff --git a/tests/html/src/tests.coffee b/tests/html/src/tests.coffee
index 9ceaa21..6dc157d 100644
--- a/tests/html/src/tests.coffee
+++ b/tests/html/src/tests.coffee
@@ -239,6 +239,7 @@ test_protocol = (protocol) ->
protocols = ['websocket',
+ 'xhr-streaming',
'iframe-eventsource',
'iframe-htmlfile',
'xhr-polling',
--
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