sockjs-client
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -0,1 +1,10 @@ | ||
1.0.1 | ||
== | ||
* Use proper base url for iframe-based info receiver - #249 | ||
* Don't register unload event in chrome packaged app - #223 | ||
* Allow custom session ids - #250 | ||
* Remove version property from bower.json - #247 | ||
* Update example CDN url - #244 | ||
1.0.0 | ||
@@ -2,0 +11,0 @@ === |
@@ -16,3 +16,3 @@ 'use strict'; | ||
function InfoIframe(url) { | ||
function InfoIframe(baseUrl, url) { | ||
var self = this; | ||
@@ -22,3 +22,3 @@ EventEmitter.call(this); | ||
var go = function() { | ||
var ifr = self.ifr = new IframeTransport(InfoReceiverIframe.transportName, url, url); | ||
var ifr = self.ifr = new IframeTransport(InfoReceiverIframe.transportName, url, baseUrl); | ||
@@ -25,0 +25,0 @@ ifr.once('message', function(msg) { |
@@ -33,3 +33,3 @@ 'use strict'; | ||
InfoReceiver._getReceiver = function(url, urlInfo) { | ||
InfoReceiver._getReceiver = function(baseUrl, url, urlInfo) { | ||
// determine method of CORS support (if needed) | ||
@@ -46,3 +46,3 @@ if (urlInfo.sameOrigin) { | ||
if (InfoIframe.enabled()) { | ||
return new InfoIframe(url); | ||
return new InfoIframe(baseUrl, url); | ||
} | ||
@@ -58,3 +58,3 @@ return new InfoAjax(url, XHRFake); | ||
this.xo = InfoReceiver._getReceiver(url, urlInfo); | ||
this.xo = InfoReceiver._getReceiver(baseUrl, url, urlInfo); | ||
@@ -61,0 +61,0 @@ this.timeoutRef = setTimeout(function() { |
@@ -53,2 +53,14 @@ 'use strict'; | ||
this._transportsWhitelist = options.transports; | ||
var sessionId = options.sessionId || 8; | ||
if (typeof sessionId === 'function') { | ||
this._generateSessionId = sessionId; | ||
} else if (typeof sessionId === 'number') { | ||
this._generateSessionId = function() { | ||
return random.string(sessionId); | ||
}; | ||
} else { | ||
throw new TypeError("If sessionId is used in the options, it needs to be a number or a function."); | ||
} | ||
this._server = options.server || random.numberString(1000); | ||
@@ -206,3 +218,3 @@ | ||
var transportUrl = urlUtils.addPath(this._transUrl, '/' + this._server + '/' + random.string(8)); | ||
var transportUrl = urlUtils.addPath(this._transUrl, '/' + this._server + '/' + this._generateSessionId()); | ||
debug('transport url', transportUrl); | ||
@@ -209,0 +221,0 @@ var transportObj = new Transport(transportUrl, this._transUrl); |
@@ -7,2 +7,4 @@ 'use strict'; | ||
, afterUnload = false | ||
// detect google chrome packaged apps because they don't allow the 'unload' event | ||
, isChromePackagedApp = global.chrome && global.chrome.app && global.chrome.app.runtime | ||
; | ||
@@ -34,2 +36,6 @@ | ||
, unloadAdd: function(listener) { | ||
if (isChromePackagedApp) { | ||
return null; | ||
} | ||
var ref = random.string(8); | ||
@@ -67,2 +73,4 @@ onUnload[ref] = listener; | ||
// can't use `beforeunload` as IE fires it on javascript: links. | ||
module.exports.attachEvent('unload', unloadTriggered); | ||
if (!isChromePackagedApp) { | ||
module.exports.attachEvent('unload', unloadTriggered); | ||
} |
@@ -1,1 +0,1 @@ | ||
module.exports = '1.0.0'; | ||
module.exports = '1.0.1'; |
{ | ||
"name": "sockjs-client", | ||
"description": "SockJS-client is a browser JavaScript library that provides a WebSocket-like object. SockJS gives you a coherent, cross-browser, Javascript API which creates a low latency, full duplex, cross-domain communication channel between the browser and the web server.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"author": "Bryce Kahle", | ||
@@ -6,0 +6,0 @@ "browser": { |
# SockJS-client [![Build Status][travis-image]][travis-url] [![Sauce Test Status](https://saucelabs.com/buildstatus/brycekahle)](https://saucelabs.com/u/brycekahle) | ||
# SockJS-client | ||
[![npm version](https://img.shields.io/npm/v/sockjs-client.svg?style=flat-square)](https://www.npmjs.com/package/sockjs-client)[![Build Status](https://img.shields.io/travis/sockjs/sockjs-client/master.svg?style=flat-square)](https://travis-ci.org/sockjs/sockjs-client)[![Dependencies](https://img.shields.io/david/sockjs/sockjs-client.svg?style=flat-square)](https://david-dm.org/sockjs/sockjs-client)[![Chat](https://img.shields.io/badge/Chat-gitter.im-blue.svg?style=flat-square)](https://gitter.im/sockjs/sockjs-client) | ||
[![Sauce Test Status](https://saucelabs.com/buildstatus/brycekahle)](https://saucelabs.com/u/brycekahle) | ||
SockJS is a browser JavaScript library that provides a WebSocket-like | ||
@@ -82,3 +85,3 @@ object. SockJS gives you a coherent, cross-browser, Javascript API | ||
```html | ||
<script src="//cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/sockjs/1.0.0/sockjs.min.js"></script> | ||
``` | ||
@@ -128,3 +131,14 @@ | ||
* **sessionId (number OR function)** | ||
Both client and server use session identifiers to distinguish connections. | ||
If you specify this option as a number, SockJS will use its random string | ||
generator function to generate session ids that are N-character long | ||
(where N corresponds to the number specified by **sessionId**). | ||
When you specify this option as a function, the function must return a | ||
randomly generated string. Every time SockJS needs to generate a session | ||
id it will call this function and use the returned string directly. | ||
If you don't specify this option, the default is to use the default random | ||
string generator to generate 8-character long session ids. | ||
Although the 'SockJS' object tries to emulate the 'WebSocket' | ||
@@ -325,3 +339,1 @@ behaviour, it's impossible to support all of its features. An | ||
[travis-url]: https://travis-ci.org/sockjs/sockjs-client?branch=master | ||
[travis-image]: http://img.shields.io/travis/sockjs/sockjs-client/master.svg |
128463
3062
337