SockJS

 view release on metacpan or  search on metacpan

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);
};

echo_factory_factory = function(protocol, messages) {
  return function() {
    var a, r;
    expect(2 + messages.length);
    a = messages.slice(0);
    r = newSockJS('/echo', protocol);
    r.onopen = function(e) {
      ok(true);
      return r.send(a[0]);
    };
    r.onmessage = function(e) {
      var i, x, xx1, xx2, _i, _ref;
      x = '' + a[0];
      if (e.data !== x) {
        for (i = _i = 0, _ref = e.data.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
          if (e.data.charCodeAt(i) !== x.charCodeAt(i)) {
            xx1 = ('0000' + x.charCodeAt(i).toString(16)).slice(-4);
            xx2 = ('0000' + e.data.charCodeAt(i).toString(16)).slice(-4);
            log('source: \\u' + xx1 + ' differs from: \\u' + xx2);
            break;
          }
        }
      }
      equal(e.data, '' + a[0]);
      a.shift();
      if (typeof a[0] === 'undefined') {
        return r.close();
      } else {
        return r.send(a[0]);
      }
    };
    return r.onclose = function(e) {
      if (a.length) {
        ok(false, "Transport closed prematurely. " + e);
      } else {
        ok(true);
      }
      return start();
    };
  };
};

factor_echo_basic = function(protocol) {
  var messages;
  messages = ['data'];
  return echo_factory_factory(protocol, messages);
};

factor_echo_rich = function(protocol) {



( run in 1.647 second using v1.01-cache-2.11-cpan-39bf76dae61 )