Example #1
0
 it('should not throw error if multiplex is off and primus-multiplex is missing', function (){
   var srv = http();
   var primus = Primus(srv, opts)
   .use('emitter', 'primus-emitter')
   .use('resource', resource);
   primus.resource('creature', {}, false);
 });
Example #2
0
  it('should throw error if `primus-multiplex` is missing', function (){
    var srv = http();
    var primus = Primus(srv, opts)
    .use('resource', resource);

    try {
      primus.resource('creature');
    } catch (e) {
      expect(e).to.be.an(Error);
      return expect(e.message).to.contain('primus-multiplex');
    }

    throw new Error('I should have throwed above');
  });
Example #3
0
  it('should emit `close` event on server when main connection is destroyed', function (done) {
    srv.listen();

    var sv = http()
      , primus = Primus(sv, opts).use('multiplex', multiplex)
      , a = primus.channel('a');

    sv.listen(function () {
      a.on('connection', function (spark) {
        primus.destroy();
      });
      a.on('close', function () {
        done();
      });
    });
    var cl = client(sv, primus)
      , cla = cl.channel('a');
  });
Example #4
0
// creates the server
function server(srv, opts) {
  return Primus(srv, opts).use('multiplex', multiplex);
}
Example #5
0
// creates the server
function server(srv, opts) {
  // use multiplex plugin
  return Primus(srv, opts).use('multiplex', multiplex);
}
Example #6
0
// creates the server
function server(srv, opts) {
  return Primus(srv, opts)
  .use('multiplex', 'primus-multiplex')
  .use('emitter', 'primus-emitter')
  .use('resource', resource);
}