Skip to content

Latest commit

 

History

History
63 lines (45 loc) · 1.13 KB

File metadata and controls

63 lines (45 loc) · 1.13 KB

Getting started with node-ivy

node-ivy is a pure Javascript implementation of the Ivy Software Bus (http://www.eei.cena.fr/products/ivy/).

Install node-ivy

npm install node-ivy

Create an ivy bus

	var IvyBus = require('node-ivy');
	...
	var ivy = new IvyBus("MyApp", "127.255.255.255", 2010);
	...
	ivy.start();

Subscribe to a given type of message

	var subId = ivy.subscribe(/myregex ([^ ]*) (.*)/, function(params){
		console.log(params);
	});
  • The regex describes the format of the messages the user wants to listen to.
  • Only messages that match the given regex will trigger the callback.
  • params is an array containing the result of every catch block defined in the regex.

Removing a previously set subscription

	ivy.unsubscribe(subId);

Send a message on the bus

	ivy.send("mymessage");

Listen for other peers on the bus

	ivy.on('peerConnected', function(peer){
		console.log("peer "+peer.name+" connected !");
	});

	ivy.on('peerQuit', function(peer){
		console.log("peer "+peer.name+" disconnected !");
	});

Quit the bus

	ivy.stop();