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

ambassador

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ambassador

Ambassador provides a way to communicate between node.js processes.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Ambassador

Ambassador provides a way to communicate between node.js processes.

With ambassador:

  • You could send JavaScript object(or other types of variables) between processes
  • You could safely kill a process which also contains ambassador.

Installation

npm install ambassador --save

Usage

First of all, ambassador is an EventEmitter.

Example

Process A (pid: 14100)

// Listen to signal 'watch'
require('ambassador').on('watch', function(pid, data){
	console.log('Signal "watch" from process[', pid, '] with data', data);
});

// So that process A will hang on.
require('http').createServer(function(){}).listen(9876);

Process B (pid: 14102)

// Send data to process 14100 (A)
require('ambassador').send(14100, 'watch', {
	abc: 1
});

Then, process A will print:

Signal "watch" from process[ 14102 ] with data {abc: 1}

Methods

ambassador.send(pid, signal, data);

Send a signal signal to the process pid with data data

Returns ambassador
pid Number

The pid of the target process

signal String

Signal name

data mixed

The data to be sent

ambassador.on(signal, callback)

Returns ambassador
signal String
callback function(pid, data)

The callback function

pid Number

The pid number from which process the signal has been sent.

data mixed

The received data

ambassador.kill(pid)

If the target process contains ambassador, this method will safely kill that process.

Keywords

FAQs

Package last updated on 26 Sep 2013

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