[Pkg-javascript-commits] [sockjs-client] 120/350: Use once where appropriate
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:03:50 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 f8184aaefe22a9c36b037445f6367a8afaa2aa25
Author: Bryce Kahle <bkahle at gmail.com>
Date: Fri Oct 10 17:44:29 2014 -0400
Use once where appropriate
---
lib/info-iframe.js | 2 +-
lib/main.js | 4 ++--
lib/transport/driver/xhr.js | 2 +-
lib/transport/facade/info-receiver-iframe.js | 2 +-
lib/transport/lib/ajax-based.js | 2 +-
lib/transport/lib/polling.js | 2 +-
lib/transport/receiver/xhr.js | 2 +-
7 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/info-iframe.js b/lib/info-iframe.js
index 1d8865f..a6f66d6 100644
--- a/lib/info-iframe.js
+++ b/lib/info-iframe.js
@@ -14,7 +14,7 @@ function InfoIframe(url) {
var go = function() {
var ifr = self.ifr = new IframeTransport('w-iframe-info-receiver', url, url);
- ifr.on('message', function (msg) {
+ ifr.once('message', function (msg) {
if (msg && msg.substr(0,1) === 'm') {
var d = JSON3.parse(msg.substr(1));
var info = d[0], rtt = d[1];
diff --git a/lib/main.js b/lib/main.js
index c704bf9..23e534e 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -93,7 +93,7 @@ function SockJS(url, protocols, transportsWhitelist) {
// obtain server info
// http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-26
this._ir = new InfoReceiver(this.url);
- this._ir.on('finish', this._receiveInfo.bind(this));
+ this._ir.once('finish', this._receiveInfo.bind(this));
}
util.inherits(SockJS, EventTarget);
@@ -175,7 +175,7 @@ SockJS.prototype._connect = function() {
var transportUrl = this._transUrl + '/' + this._server + '/' + random.string(8);
var transport = new Transport(transportUrl, this._transUrl);
transport.on('message', this._transportMessage.bind(this));
- transport.on('close', this._transportClose.bind(this));
+ transport.once('close', this._transportClose.bind(this));
this._transport = transport;
return;
diff --git a/lib/transport/driver/xhr.js b/lib/transport/driver/xhr.js
index e459e97..e284376 100644
--- a/lib/transport/driver/xhr.js
+++ b/lib/transport/driver/xhr.js
@@ -27,7 +27,7 @@ function XhrDriver(method, url, payload, opts) {
res.on('data', function (chunk) {
responseText += chunk;
});
- res.on('end', function () {
+ res.once('end', function () {
self.emit('finish', res.statusCode, responseText);
self.req = null;
});
diff --git a/lib/transport/facade/info-receiver-iframe.js b/lib/transport/facade/info-receiver-iframe.js
index ff5e1fa..af1fb68 100644
--- a/lib/transport/facade/info-receiver-iframe.js
+++ b/lib/transport/facade/info-receiver-iframe.js
@@ -12,7 +12,7 @@ function WInfoReceiverIframe(transUrl, baseUrl) {
EventEmitter.call(this);
var ir = new InfoReceiver(baseUrl, XHRLocalObject);
- ir.on('finish', function(info, rtt) {
+ ir.once('finish', function(info, rtt) {
self.emit('message', 'm' + JSON3.stringify([info, rtt]) );
self.emit('close');
});
diff --git a/lib/transport/lib/ajax-based.js b/lib/transport/lib/ajax-based.js
index b62d854..a615283 100644
--- a/lib/transport/lib/ajax-based.js
+++ b/lib/transport/lib/ajax-based.js
@@ -11,7 +11,7 @@ function createAjaxSender(AjaxObject) {
opt.headers = {'Content-type':'text/plain'};
}
var xo = new AjaxObject('POST', url + '/xhr_send', payload, opt);
- xo.on('finish', function(status) {
+ xo.once('finish', function(status) {
if (status !== 200 && status !== 204) {
return callback(new Error('http status ' + status));
}
diff --git a/lib/transport/lib/polling.js b/lib/transport/lib/polling.js
index 4e0185a..86cbb2c 100644
--- a/lib/transport/lib/polling.js
+++ b/lib/transport/lib/polling.js
@@ -22,7 +22,7 @@ Polling.prototype._scheduleReceiver = function() {
self.emit('message', msg);
});
- poll.on('close', function(code, reason) {
+ poll.once('close', function(code, reason) {
self.poll = poll = null;
if (!self.pollIsClosing) {
diff --git a/lib/transport/receiver/xhr.js b/lib/transport/receiver/xhr.js
index 542320c..2331f04 100644
--- a/lib/transport/receiver/xhr.js
+++ b/lib/transport/receiver/xhr.js
@@ -10,7 +10,7 @@ function XhrReceiver(url, AjaxObject) {
this.xo = new AjaxObject('POST', url, null);
this.xo.on('chunk', this._chunkHandler.bind(this));
- this.xo.on('finish', function(status, text) {
+ this.xo.once('finish', function(status, text) {
self._chunkHandler(status, text);
self.xo = null;
var reason = status === 200 ? 'network' : 'permanent';
--
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