npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

public_radio

v0.0.4

Published

Build highly distributed services by allowing your node applications to share emitted events over tcp socket connections.

Downloads

5

Readme

Topology

Build highly distributed services by allowing your node applications to share emitted events over tcp socket connections.

How it works and what its for

Applications can act as a server (allowing for incoming connections) or a client (connecting to a server). When a connection is made the stream is then converted to an event emitter using @substack's emit-stream. The advantage of Public Radio is that it allows you to create a graph of nodes made up of server and clients that can emit events that will be received by all the other nodes, as well as allowing them to bind callbacks to specific events they are interested in.

Build
Status

Usage

Creating a server that will listen for incoming connections

var Server = require('public_radio').PublicRadio;

var server = new Server(5000);

server.listen();

Creating a client to connect to a server

var Client = require('public_radio').PublicRadioClient;

var client = new Client('localhost', 5000);

client.on('connected', function(conn) {
  // do something with connection
});

client.connect();

Connect servers to other servers to share your events with them and their clients


server.linkTo('localhost', 5001);

Setting up a listener for an event on a server


server.events().on('stock_update', function(symbol, price) {
  // work with stock update
});

Emitting an event from a server


server.broadcast('stock_update', 'GOOG', 15.43);

Setting up a listener for an event on a client


client.on('connected', function(conn) {
  conn.on('stock_update', function(symbol, price) {
    // work with stock update
  });
});

Emitting an event from the client


client.on('connected', function(conn) {

  conn.emit('stock_update', 'GOOG', 15.43);

});

or


client.connection.emit('stock_update', 'GOOG', 15.43);

Bigger Picture

Topology

Setting up this network


var Server = require('public_radio').PublicRadio,
    Client = require('public_radio').PublicRadioClient;

var server1 = (new Server(5000)).listen(),
    server2 = (new Server(5001)).listen();

server1.linkTo('localhost', 5001);

var client1 = (new Client('localhost', 5000)),
    client2 = (new Client('localhost', 5000)),
    client3 = (new Client('localhost', 5001));

client1.on('connected', function(conn) {

});

client1.connect();

client2.on('connected', function(conn) {

});

client2.connect();

client3.on('connected', function(conn) {

});

client3.connect();