[Pkg-javascript-commits] [sockjs-client] 345/350: Add way to specify transport-specific options using `transportOptions` hash.
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:04:37 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 783d1fe0b4b528b3c09f1f13c049d2737b786e1a
Author: Bryce Kahle <bkahle at gmail.com>
Date: Sat Apr 30 14:35:33 2016 -0700
Add way to specify transport-specific options using `transportOptions` hash.
Fixes #272
---
lib/main.js | 4 +++-
lib/transport/websocket.js | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/main.js b/lib/main.js
index 8d86d94..10b1a41 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -48,6 +48,7 @@ function SockJS(url, protocols, options) {
log.warn("'protocols_whitelist' is DEPRECATED. Use 'transports' instead.");
}
this._transportsWhitelist = options.transports;
+ this._transportOptions = options.transportOptions || {};
var sessionId = options.sessionId || 8;
if (typeof sessionId === 'function') {
@@ -213,8 +214,9 @@ SockJS.prototype._connect = function() {
debug('using timeout', timeoutMs);
var transportUrl = urlUtils.addPath(this._transUrl, '/' + this._server + '/' + this._generateSessionId());
+ var options = this._transportOptions[Transport.transportName];
debug('transport url', transportUrl);
- var transportObj = new Transport(transportUrl, this._transUrl);
+ var transportObj = new Transport(transportUrl, this._transUrl, options);
transportObj.on('message', this._transportMessage.bind(this));
transportObj.once('close', this._transportClose.bind(this));
transportObj.transportName = Transport.transportName;
diff --git a/lib/transport/websocket.js b/lib/transport/websocket.js
index 8e0b597..55d5d5b 100644
--- a/lib/transport/websocket.js
+++ b/lib/transport/websocket.js
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:websocket');
}
-function WebSocketTransport(transUrl) {
+function WebSocketTransport(transUrl, ignore, options) {
if (!WebSocketTransport.enabled()) {
throw new Error('Transport created when disabled');
}
@@ -29,7 +29,7 @@ function WebSocketTransport(transUrl) {
}
this.url = url;
- this.ws = new WebsocketDriver(this.url);
+ this.ws = new WebsocketDriver(this.url, undefined, options);
this.ws.onmessage = function(e) {
debug('message event', e.data);
self.emit('message', e.data);
--
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