view release on metacpan or search on metacpan
t/middleware/jsessionid.t
t/session.t
t/transport/base.t
t/transport/event-source.t
t/transport/htmlfile.t
t/transport/jsonp-polling.t
t/transport/jsonp-send.t
t/transport/websocket.t
t/transport/xhr-polling.t
t/transport/xhr-send.t
t/transport/xhr-streaming.t
META.yml
MANIFEST
example/public/sockjs-0.3.4.min.js view on Meta::CPAN
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// JSON2 by Douglas Crockford (minified).
var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number...
SockJS=function(){var a=document,b=window,c={},d=function(){};d.prototype.addEventListener=function(a,b){this._listeners||(this._listeners={}),a in this._listeners||(this._listeners[a]=[]);var d=this._listeners[a];c.arrIndexOf(d,b)===-1&&d.push(b);re...
lib/SockJS/Transport.pm view on Meta::CPAN
my $path = shift;
my $class;
if ($path eq 'xhr') {
$class = 'XHRPolling';
}
elsif ($path eq 'xhr_send') {
$class = 'XHRSend';
}
elsif ($path eq 'xhr_streaming') {
$class = 'XHRStreaming';
}
if ($path eq 'jsonp') {
$class = 'JSONPPolling';
}
elsif ($path eq 'jsonp_send') {
$class = 'JSONPSend';
}
elsif ($path eq 'websocket' || $path eq 'raw_websocket') {
$class = 'WebSocket';
t-vendor/app.psgi view on Meta::CPAN
[
200,
[
'Content-Type' => 'text/plain',
'Access-Control-Allow-Origin' => '*'
],
[$body]
];
};
mount '/streaming.txt' => sub {
my $env = shift;
my $t;
return sub {
my $respond = shift;
my $writer = $respond->(
[
200,
t-vendor/html/example-cursors.html view on Meta::CPAN
</style>
</head>
<body>
<form>
<select id="transport">
<option value="">- any - </option>
<option value="websocket">websocket</option>
<option value="not-websocket">- not websocket -</option>
<option value="xdr-streaming">xdr-streaming</option>
<option value="xhr-streaming">xhr-streaming</option>
<option value="iframe-eventsource">iframe-eventsource</option>
<option value="iframe-htmlfile">iframe-htmlfile</option>
<option value="xdr-polling">xdr-polling</option>
<option value="xhr-polling">xhr-polling</option>
<option value="iframe-xhr-polling">iframe-xhr-polling</option>
<option value="jsonp-polling">jsonp-polling</option>
</select>
<input type="button" value="Connect" id="connect">
<input type="button" value="Disconnect" id="disconnect" disabled="yes">
</form>
t-vendor/html/example-cursors.html view on Meta::CPAN
$('#logs').scrollTop($('#logs').scrollTop()+10000);
}
var sjs = null;
var protocol;
$('#connect').click(function() {
$('#connect').attr('disabled', true);
$('#disconnect').each(function(_,e){e.disabled='';});
var protocol = $('#transport').val() || undefined;
if (protocol === 'not-websocket') {
protocol = ['xdr-streaming',
'xhr-streaming',
'iframe-eventsource',
'iframe-htmlfile',
'xdr-polling',
'xhr-polling',
'iframe-xhr-polling',
'jsonp-polling'];
}
log('[connecting] ' + protocol);
options = jQuery.extend({}, client_opts.sockjs_opts)
options.protocols_whitelist = typeof protocol === 'string' ?
t-vendor/html/lib/domtests.js view on Meta::CPAN
// Generated by CoffeeScript 1.6.1
var ajax_simple_factory, ajax_streaming_factory, ajax_wrong_port_factory, newIframe, onunload_test_factory, test_wrong_url, u;
module('Dom');
u = SockJS.getUtils();
newIframe = function(path) {
var err, hook;
if (path == null) {
path = '/iframe.html';
}
t-vendor/html/lib/domtests.js view on Meta::CPAN
expect(2);
x = new u[name]('GET', '/simple.txt', null);
return x.onfinish = function(status, text) {
equal(text.length, 2051);
equal(text.slice(-2), 'b\n');
return start();
};
});
};
ajax_streaming_factory = function(name) {
return asyncTest(name + ' streaming', function() {
var x;
expect(4);
x = new u[name]('GET', '/streaming.txt', null);
x.onchunk = function(status, text) {
equal(status, 200);
ok(text.length <= 2049, 'Most likely you\'re behind a transparent Proxy that can\'t do streaming. QUnit tests won\'t work properly. Sorry!');
return delete x.onchunk;
};
return x.onfinish = function(status, text) {
equal(status, 200);
equal(text.slice(-4), 'a\nb\n');
return start();
};
});
};
t-vendor/html/lib/domtests.js view on Meta::CPAN
return _results;
};
ajax_simple_factory('XHRLocalObject');
if (window.XDomainRequest) {
ajax_simple_factory('XDRObject');
}
if (!window.ActiveXObject) {
ajax_streaming_factory('XHRLocalObject');
}
if (window.XDomainRequest) {
ajax_streaming_factory('XDRObject');
}
ajax_wrong_port_factory('XHRLocalObject');
if (window.XDomainRequest) {
ajax_wrong_port_factory('XDRObject');
}
asyncTest('XHRLocalObject wrong url', function() {
return test_wrong_url('XHRLocalObject', '/wrong_url_indeed.txt', [0, 404]);
t-vendor/html/lib/endtoendtests.js view on Meta::CPAN
r.close();
return u.delay(10, function() {
return start();
});
};
});
asyncTest("EventEmitter exception handling", function() {
var prev_onerror, r;
expect(1);
r = newSockJS('/echo', 'xhr-streaming');
prev_onerror = window.onerror;
window.onerror = function(e) {
ok(/onopen error/.test('' + e));
window.onerror = prev_onerror;
return r.close();
};
r.onopen = function(e) {
throw "onopen error";
};
return r.onclose = function() {
t-vendor/html/lib/sockjs.js view on Meta::CPAN
}
if(!extra_lookup) extra_lookup = unroll_lookup(extra_escapable);
return quoted.replace(extra_escapable, function(a) {
return extra_lookup[a];
});
}
var _all_protocols = ['websocket',
'xdr-streaming',
'xhr-streaming',
'iframe-eventsource',
'iframe-htmlfile',
'xdr-polling',
'xhr-polling',
'iframe-xhr-polling',
'jsonp-polling'];
utils.probeProtocols = function() {
var probed = {};
for(var i=0; i<_all_protocols.length; i++) {
t-vendor/html/lib/sockjs.js view on Meta::CPAN
}
}
}
// 1. Websocket
if (info.websocket !== false) {
maybe_push(['websocket']);
}
// 2. Streaming
if (pe['xhr-streaming'] && !info.null_origin) {
protocols.push('xhr-streaming');
} else {
if (pe['xdr-streaming'] && !info.cookie_needed && !info.null_origin) {
protocols.push('xdr-streaming');
} else {
maybe_push(['iframe-eventsource',
'iframe-htmlfile']);
}
}
// 3. Polling
if (pe['xhr-polling'] && !info.null_origin) {
protocols.push('xhr-polling');
} else {
t-vendor/html/lib/sockjs.js view on Meta::CPAN
};
AjaxBasedTransport.prototype.doCleanup = function() {
var that = this;
if (that.poll) {
that.poll.abort();
that.poll = null;
}
};
// xhr-streaming
var XhrStreamingTransport = SockJS['xhr-streaming'] = function(ri, trans_url) {
this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XHRCorsObject);
};
XhrStreamingTransport.prototype = new AjaxBasedTransport();
XhrStreamingTransport.enabled = function() {
// Support for CORS Ajax aka Ajax2? Opera 12 claims CORS but
// doesn't do streaming.
return (_window.XMLHttpRequest &&
'withCredentials' in new XMLHttpRequest() &&
(!/opera/i.test(navigator.userAgent)));
};
XhrStreamingTransport.roundTrips = 2; // preflight, ajax
// Safari gets confused when a streaming ajax request is started
// before onload. This causes the load indicator to spin indefinetely.
XhrStreamingTransport.need_body = true;
// 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/
// xdr-streaming
var XdrStreamingTransport = SockJS['xdr-streaming'] = function(ri, trans_url) {
this.run(ri, trans_url, '/xhr_streaming', XhrReceiver, utils.XDRObject);
};
XdrStreamingTransport.prototype = new AjaxBasedTransport();
XdrStreamingTransport.enabled = function() {
return !!_window.XDomainRequest;
};
XdrStreamingTransport.roundTrips = 2; // preflight, ajax
t-vendor/html/lib/tests.js view on Meta::CPAN
// Generated by CoffeeScript 1.6.1
var arrIndexOf, batch_factory_factory, batch_factory_factory_amp, echo_factory_factory, escapable, factor_batch_large, factor_batch_large_amp, factor_echo_basic, factor_echo_large_message, factor_echo_rich, factor_echo_special_chars, factor_echo_unic...
protocols = ['websocket', 'xdr-streaming', 'xhr-streaming', 'iframe-eventsource', 'iframe-htmlfile', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling'];
newSockJS = function(path, protocol) {
var options, url;
url = /^http/.test(path) ? path : client_opts.url + path;
options = jQuery.extend({}, client_opts.sockjs_opts);
if (protocol) {
options.protocols_whitelist = [protocol];
}
return new SockJS(url, null, options);
};
t-vendor/html/lib/unittests.js view on Meta::CPAN
return _results;
})();
all_chars = c.join('');
return ok(JSON.parse(u.quote(all_chars)) === all_chars, "Quote/unquote all 64K chars.");
});
test('detectProtocols', function() {
var chrome_probed, ie10_probed, ie6_probed, ie8_probed, opera_probed;
chrome_probed = {
'websocket': true,
'xdr-streaming': false,
'xhr-streaming': true,
'iframe-eventsource': true,
'iframe-htmlfile': true,
'xdr-polling': false,
'xhr-polling': true,
'iframe-xhr-polling': true,
'jsonp-polling': true
};
deepEqual(u.detectProtocols(chrome_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
deepEqual(u.detectProtocols(chrome_probed, null, {
websocket: false
}), ['xhr-streaming', 'xhr-polling']);
opera_probed = {
'websocket': false,
'xdr-streaming': false,
'xhr-streaming': false,
'iframe-eventsource': true,
'iframe-htmlfile': true,
'xdr-polling': false,
'xhr-polling': false,
'iframe-xhr-polling': true,
'jsonp-polling': true
};
deepEqual(u.detectProtocols(opera_probed, null, {}), ['iframe-eventsource', 'iframe-xhr-polling']);
ie6_probed = {
'websocket': false,
'xdr-streaming': false,
'xhr-streaming': false,
'iframe-eventsource': false,
'iframe-htmlfile': false,
'xdr-polling': false,
'xhr-polling': false,
'iframe-xhr-polling': false,
'jsonp-polling': true
};
deepEqual(u.detectProtocols(ie6_probed, null, {}), ['jsonp-polling']);
ie8_probed = {
'websocket': false,
'xdr-streaming': true,
'xhr-streaming': false,
'iframe-eventsource': false,
'iframe-htmlfile': true,
'xdr-polling': true,
'xhr-polling': false,
'iframe-xhr-polling': true,
'jsonp-polling': true
};
deepEqual(u.detectProtocols(ie8_probed, null, {}), ['xdr-streaming', 'xdr-polling']);
deepEqual(u.detectProtocols(ie8_probed, null, {
cookie_needed: true
}), ['iframe-htmlfile', 'iframe-xhr-polling']);
ie10_probed = {
'websocket': true,
'xdr-streaming': true,
'xhr-streaming': true,
'iframe-eventsource': false,
'iframe-htmlfile': true,
'xdr-polling': true,
'xhr-polling': true,
'iframe-xhr-polling': true,
'jsonp-polling': true
};
deepEqual(u.detectProtocols(ie10_probed, null, {}), ['websocket', 'xhr-streaming', 'xhr-polling']);
deepEqual(u.detectProtocols(ie10_probed, null, {
cookie_needed: true
}), ['websocket', 'xhr-streaming', 'xhr-polling']);
deepEqual(u.detectProtocols(chrome_probed, null, {
null_origin: true
}), ['websocket', 'iframe-eventsource', 'iframe-xhr-polling']);
deepEqual(u.detectProtocols(chrome_probed, null, {
websocket: false,
null_origin: true
}), ['iframe-eventsource', 'iframe-xhr-polling']);
deepEqual(u.detectProtocols(opera_probed, null, {
null_origin: true
}), ['iframe-eventsource', 'iframe-xhr-polling']);
t-vendor/html/smoke-latency.html view on Meta::CPAN
<script type="text/javascript" src="lib/sockjs.js"></script>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript" src="config.js"></script>
</head>
<body>
<form>
<select id="transport">
<option value="">- any - </option>
<option value="websocket">websocket</option>
<option value="xdr-streaming">xdr-streaming</option>
<option value="xhr-streaming">xhr-streaming</option>
<option value="iframe-eventsource">iframe-eventsource</option>
<option value="iframe-htmlfile">iframe-htmlfile</option>
<option value="xdr-polling">xdr-polling</option>
<option value="xhr-polling">xhr-polling</option>
<option value="iframe-xhr-polling">iframe-xhr-polling</option>
<option value="jsonp-polling">jsonp-polling</option>
</select>
<input type="button" value="Connect" id="connect">
<input type="button" value="Disconnect" id="disconnect" disabled="yes">
</form>
t-vendor/html/smoke-reconnect.html view on Meta::CPAN
<script type="text/javascript" src="lib/sockjs.js"></script>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript" src="config.js"></script>
</head>
<body>
<form>
<select id="transport">
<option value="">- any - </option>
<option value="websocket">websocket</option>
<option value="xdr-streaming">xdr-streaming</option>
<option value="xhr-streaming">xhr-streaming</option>
<option value="iframe-eventsource">iframe-eventsource</option>
<option value="iframe-htmlfile">iframe-htmlfile</option>
<option value="xdr-polling">xdr-polling</option>
<option value="xhr-polling">xhr-polling</option>
<option value="iframe-xhr-polling">iframe-xhr-polling</option>
<option value="jsonp-polling">jsonp-polling</option>
</select>
<input type="button" value="Start" id="connect">
<input type="button" value="Stop" id="disconnect" disabled="yes">
</form>
t-vendor/html/src/domtests.coffee view on Meta::CPAN
ajax_simple_factory = (name) ->
asyncTest name + ' simple', ->
expect(2)
x = new u[name]('GET', '/simple.txt', null)
x.onfinish = (status, text) ->
equal(text.length, 2051)
equal(text.slice(-2), 'b\n')
start()
ajax_streaming_factory = (name) ->
asyncTest name + ' streaming', ->
expect(4)
x = new u[name]('GET', '/streaming.txt', null)
x.onchunk = (status, text) ->
equal(status, 200)
ok(text.length <= 2049, 'Most likely you\'re behind a transparent Proxy that can\'t do streaming. QUnit tests won\'t work properly. Sorry!')
delete x.onchunk
x.onfinish = (status, text) ->
equal(status, 200)
equal(text.slice(-4), 'a\nb\n')
start()
test_wrong_url = (name, url, statuses) ->
if window.console and console.log
console.log(' [*] Connecting to wrong url ' + url)
t-vendor/html/src/domtests.coffee view on Meta::CPAN
for port in [25, 8999, 65300]
asyncTest name + ' wrong port ' + port, ->
test_wrong_url(name, 'http://localhost:'+port+'/wrong_url_indeed.txt', [0])
ajax_simple_factory('XHRLocalObject')
if window.XDomainRequest
ajax_simple_factory('XDRObject')
if not window.ActiveXObject
# Ajax streaming is not working in ie.
ajax_streaming_factory('XHRLocalObject')
if window.XDomainRequest
ajax_streaming_factory('XDRObject')
ajax_wrong_port_factory('XHRLocalObject')
if window.XDomainRequest
ajax_wrong_port_factory('XDRObject')
asyncTest 'XHRLocalObject wrong url', ->
# Opera responds with 0, all other browsers with 404
test_wrong_url('XHRLocalObject', '/wrong_url_indeed.txt', [0, 404])
if window.XDomainRequest
asyncTest 'XDRObject wrong url', ->
t-vendor/html/src/endtoendtests.coffee view on Meta::CPAN
r.onclose = ->
ok(false)
r.close()
u.delay 10, ->
start()
# Test for #61
asyncTest "EventEmitter exception handling", ->
expect(1)
r = newSockJS('/echo', 'xhr-streaming')
prev_onerror = window.onerror
window.onerror = (e) ->
ok(/onopen error/.test(''+e))
window.onerror = prev_onerror
r.close()
r.onopen = (e) ->
throw "onopen error"
r.onclose = ->
start()
t-vendor/html/src/tests.coffee view on Meta::CPAN
protocols = ['websocket',
'xdr-streaming',
'xhr-streaming',
'iframe-eventsource',
'iframe-htmlfile',
'xdr-polling',
'xhr-polling',
'iframe-xhr-polling',
'jsonp-polling']
newSockJS = (path, protocol) ->
url = if /^http/.test(path) then path else client_opts.url + path
options = jQuery.extend({}, client_opts.sockjs_opts)
t-vendor/html/src/tests.coffee view on Meta::CPAN
"\ufffd",
"\ufffd\u0000",
"message\ufffd",
"\ufffdmessage",
]
return echo_factory_factory(protocol, messages)
factor_echo_large_message = (protocol) ->
# Should be larger than 128k - the limit for a single request in
# some streaming transports.
messages = [
Array(Math.pow(2,1)).join('x'),
Array(Math.pow(2,2)).join('x'),
Array(Math.pow(2,4)).join('x'),
Array(Math.pow(2,8)).join('x'),
Array(Math.pow(2,13)).join('x'),
Array(Math.pow(2,13)).join('x'),
]
return echo_factory_factory(protocol, messages)
t-vendor/html/src/unittests.coffee view on Meta::CPAN
# And a sanity check.
c = for i in [0..65535]
String.fromCharCode(i)
all_chars = c.join('')
ok(JSON.parse(u.quote(all_chars)) is all_chars, "Quote/unquote all 64K chars.")
test 'detectProtocols', ->
chrome_probed = {
'websocket': true
'xdr-streaming': false
'xhr-streaming': true
'iframe-eventsource': true
'iframe-htmlfile': true
'xdr-polling': false
'xhr-polling': true
'iframe-xhr-polling': true
'jsonp-polling': true
}
# Chrome
deepEqual(u.detectProtocols(chrome_probed, null, {}),
['websocket', 'xhr-streaming', 'xhr-polling'])
deepEqual(u.detectProtocols(chrome_probed, null, {websocket:false}),
['xhr-streaming', 'xhr-polling'])
# Opera
opera_probed = {
'websocket': false
'xdr-streaming': false
'xhr-streaming': false
'iframe-eventsource': true
'iframe-htmlfile': true
'xdr-polling': false
'xhr-polling': false
'iframe-xhr-polling': true
'jsonp-polling': true
}
deepEqual(u.detectProtocols(opera_probed, null, {}),
['iframe-eventsource', 'iframe-xhr-polling'])
# IE 6, IE 7
ie6_probed = {
'websocket': false
'xdr-streaming': false
'xhr-streaming': false
'iframe-eventsource': false
'iframe-htmlfile': false
'xdr-polling': false
'xhr-polling': false
'iframe-xhr-polling': false
'jsonp-polling': true
}
deepEqual(u.detectProtocols(ie6_probed, null, {}),
['jsonp-polling'])
# IE 8, IE 9
ie8_probed = {
'websocket': false
'xdr-streaming': true
'xhr-streaming': false
'iframe-eventsource': false
'iframe-htmlfile': true
'xdr-polling': true
'xhr-polling': false
'iframe-xhr-polling': true
'jsonp-polling': true
}
deepEqual(u.detectProtocols(ie8_probed, null, {}),
['xdr-streaming', 'xdr-polling'])
deepEqual(u.detectProtocols(ie8_probed, null, {cookie_needed:true}),
['iframe-htmlfile', 'iframe-xhr-polling'])
# IE 10
ie10_probed = {
'websocket': true
'xdr-streaming': true
'xhr-streaming': true
'iframe-eventsource': false
'iframe-htmlfile': true
'xdr-polling': true
'xhr-polling': true
'iframe-xhr-polling': true
'jsonp-polling': true
}
deepEqual(u.detectProtocols(ie10_probed, null, {}),
['websocket', 'xhr-streaming', 'xhr-polling'])
deepEqual(u.detectProtocols(ie10_probed, null, {cookie_needed:true}),
['websocket', 'xhr-streaming', 'xhr-polling'])
# Check if protocols are picked up correctly when served from file://
deepEqual(u.detectProtocols(chrome_probed, null, {null_origin:true}),
['websocket', 'iframe-eventsource', 'iframe-xhr-polling'])
deepEqual(u.detectProtocols(chrome_probed, null,
{websocket:false, null_origin:true}),
['iframe-eventsource', 'iframe-xhr-polling'])
deepEqual(u.detectProtocols(opera_probed, null, {null_origin:true}),
['iframe-eventsource', 'iframe-xhr-polling'])
t-vendor/sockjs-0.3.2.min.js view on Meta::CPAN
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
// JSON2 by Douglas Crockford (minified).
var JSON;JSON||(JSON={}),function(){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number...
SockJS=function(){var a=document,b=window,c={},d=function(){};d.prototype.addEventListener=function(a,b){this._listeners||(this._listeners={}),a in this._listeners||(this._listeners[a]=[]);var d=this._listeners[a];c.arrIndexOf(d,b)===-1&&d.push(b);re...
t-vendor/sockjs.min.js view on Meta::CPAN
/* sockjs-client v1.1.5 | http://sockjs.org | MIT license */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof se...
i.onerror=this._scriptError.bind(this),i.onload=function(){r._abort(new Error("JSONP script loaded abnormally (onload)"))},i.onreadystatechange=function(){if(i.readyState,/loaded|closed/.test(i.readyState)){if(i&&i.htmlFor&&i.onclick){r.loadedOkay=!0...
//# sourceMappingURL=sockjs.min.js.map