Simple_pubsub is a project mainly written in CoffeeScript, it's free.
Simple PUBSUB server and client for Node.js and CoffeeScript
A publisher publishes a message on a channel which is just a string name. A subscriber subscribed to the channel will be forwarded the published message.
This server is meant for internal/backend use only. Publishers and subscribers talk to a PUBSUB server over TCP/IP.
The NPM package is JavaScript compiled from CoffeeScript. Use the git repository to work with the CoffeeScript version.
npm install simple_pubsub
simple_pubsub_server [OPTIONS]
--listen <ip:port> Default: 127.0.0.1:9912
--loglevel <level> Default: error
var client = require('simple_pubsub').connect();
var timer_id = setInterval(function () {
client.publish(new Date(), 'current-time');
}, 1000);
client.on('io-error', function (err) {
clearInterval(timer_id);
});
require('simple_pubsub').connect().subscribe('current-time', function (msg, chan) {
console.log("The time is " + msg);
});
Returns a SimplePubsubClient object.
An input/output error occurred.
Someone wrote a malformed message.
All messages that are received due to some subscription.
Subscribe to a channel 'chan' and call back function 'cb' with the msg
and chan
when a message is published to 'chan'.
Unsubscribe from channel 'chan'.
Publish a message 'msg' to channel 'chan'.
System messages are published on a reserved channel named simplepubsub
.
All clients are implicitly subscribed to this channel.
Wildcard channel names are unsupported; publishers and subscribers must use literal channel names, not patterns.
Offline storage is unsupported.
All messages are encoded as CRLF delimited JSON objects.
A client subscribes to a channel.
{ sub: 'channel' }
A client publishes a message to one or more channels. The same message is forwarded to subscribers.
{ pub: { msg: value, chan: 'channel' } }
Brian Hammond [email protected] (http://fictorial.com)
MIT