New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

revents

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

revents

Connect two EventEmitters via a socket.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
Source

revents

Connect two EventEmitters via a socket.

Build Status Test Coverage License: MIT

bitHound Code bitHound Overall Score bitHound Dependencies

Installation

npm i revents

Example

In the server.js file:

const { RemoteEventEmitter: Connection } = require('revents')
const net = require('net')

const server = net.createServer(socket => {
  const connection = new Connection(socket)

  connection.remoteEmit('ping')

  connection.on('pong', () => {
    console.log('pong')
  })
})

server.listen(8080)

In the client.js file:

const { RemoteEventEmitter } = require('revents')
const net = require('net')

const socket = net.connect(8080)
const connection = new Connection(socket)

connection.remoteEmit('pong')

connection.on('ping', () => {
  console.log('ping')
}

API

The RemoteEventEmitter extends the Connection class from the socket-json-wrapper package. This means that you can use the send method and the "message" event.

emitter.remoteEmit(event, ...args)

  • event <string> - The name of the event.
  • ...args <any> - Arguments for the event.

Emit an event on the EventEmitter on the other side of the socket connection. It returns a <boolean> that is true if the event was written to the socket.

Keywords

socket

FAQs

Package last updated on 29 Oct 2017

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