[Pkg-javascript-commits] [sockjs-client] 164/350: Add node eventsource

tonnerre at ancient-solutions.com tonnerre at ancient-solutions.com
Fri Aug 5 01:03:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.

commit 3d4e9844a4f1fb45279e1577abd28860a434a6d9
Author: Bryce Kahle <bkahle at gmail.com>
Date:   Fri Oct 17 14:19:59 2014 -0400

    Add node eventsource
---
 lib/transport/browser/eventsource.js  | 1 +
 lib/transport/driver/eventsource.js   | 1 +
 lib/transport/eventsource.js          | 3 ++-
 lib/transport/receiver/eventsource.js | 3 ++-
 package.json                          | 2 ++
 5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/transport/browser/eventsource.js b/lib/transport/browser/eventsource.js
new file mode 100644
index 0000000..719c69c
--- /dev/null
+++ b/lib/transport/browser/eventsource.js
@@ -0,0 +1 @@
+module.exports = global.EventSource;
diff --git a/lib/transport/driver/eventsource.js b/lib/transport/driver/eventsource.js
new file mode 100644
index 0000000..6c8d649
--- /dev/null
+++ b/lib/transport/driver/eventsource.js
@@ -0,0 +1 @@
+module.exports = require('eventsource');
diff --git a/lib/transport/eventsource.js b/lib/transport/eventsource.js
index d6a613f..53805a0 100644
--- a/lib/transport/eventsource.js
+++ b/lib/transport/eventsource.js
@@ -4,6 +4,7 @@ var util = require('util')
   , AjaxBasedTransport = require('./lib/ajax-based')
   , EventSourceReceiver = require('./receiver/eventsource')
   , XHRCorsObject = require('./sender/xhr-cors')
+  , EventSourceDriver = require('./driver/eventsource')
   ;
 
 function EventSourceTransport(transUrl) {
@@ -13,7 +14,7 @@ function EventSourceTransport(transUrl) {
 util.inherits(EventSourceTransport, AjaxBasedTransport);
 
 EventSourceTransport.enabled = function () {
-  return ('EventSource' in global);
+  return !!EventSourceDriver;
 };
 
 EventSourceTransport.transportName = 'eventsource';
diff --git a/lib/transport/receiver/eventsource.js b/lib/transport/receiver/eventsource.js
index edb4af9..728a9f9 100644
--- a/lib/transport/receiver/eventsource.js
+++ b/lib/transport/receiver/eventsource.js
@@ -3,6 +3,7 @@
 var util = require('util')
   , EventEmitter = require('events').EventEmitter
   , debug = require('debug')('sockjs-client:receiver:eventsource')
+  , EventSourceDriver = require('../driver/eventsource')
   ;
 
 function EventSourceReceiver(url) {
@@ -10,7 +11,7 @@ function EventSourceReceiver(url) {
   EventEmitter.call(this);
 
   var self = this;
-  var es = this.es = new global.EventSource(url);
+  var es = this.es = new EventSourceDriver(url);
   es.onmessage = function(e) {
     debug('message', e.data);
     self.emit('message', decodeURI(e.data));
diff --git a/package.json b/package.json
index e81db5c..ab42eed 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
   "author": "Bryce Kahle",
   "browser": {
     "./lib/transport/driver/websocket.js": "./lib/transport/browser/websocket.js",
+    "./lib/transport/driver/eventsource.js": "./lib/transport/browser/eventsource.js",
     "./lib/transport/driver/xhr.js": "./lib/transport/browser/abstract-xhr.js",
     "crypto": "./lib/utils/browser-crypto.js"
   },
@@ -22,6 +23,7 @@
     }
   ],
   "dependencies": {
+    "eventsource": "^0.1.3",
     "faye-websocket": "~0.7.3",
     "json3": "^3.3.2"
   },

-- 
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