Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cio/duplex-emitter

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cio/duplex-emitter

Configure connection with duplex-emitter

  • 0.2.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
Weekly downloads
 
Created
Source

@cio/duplex-emitter

Build Status Dependency Status npm version

Use two way event system for client/server communication.

Uses module duplex-emitter.

Install

npm install @cio/duplex-emitter --save

Usage

Uses duplex-emitter to setup a two-way remote event communication.

Enable it with the duplexEmitter:true options property and it will produce a socket.duplexEmitter sub-property and emit a 'duplex-emitter' event.

// get the `cio` module's builder function and build one
var buildCio = require('cio')
  , cio = buildCio();

// provide the module name to load it for the specific type of socket
cio.onClient('@cio/duplex-emitter');
cio.onServerClient('@cio/duplex-emitter');

// OR: provide the function
var fn = require('@cio/duplex-emitter');
cio.onClient(fn);
cio.onServerClient(fn);


// tell this listener to do its thing for this client
var options = { duplexEmitter:true }
  , client = cio.client(options)
  , server = cio.server(options);

// the result is sockets connect (client and server client) it will do:
//   socket.duplexEmitter = DuplexEmitter(socket);
//   socket.emit('duplex-emitter', socket.duplexEmitter, socket);
// so, you can do this for both `client` and `server`
client.on('duplex-emitter', function(emitter, socket) {
  emitter.on('some-event', someListener);
  // and more...
});
// NOTE: it emits 'emitter' in `nextTick()` so you have a chance to add
// a listener for that event before it is emitted.

// if you specify key/cert, and optionally `ca`, values
// then it'll use `tls.connect()` instead for secure communication.

MIT License

Keywords

FAQs

Package last updated on 05 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc