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

autohost-pubsub

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autohost-pubsub

A backbone that allows clients to manage subscriptions to system-wide events.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

autohost-pubsub

A backbone that allows clients to manage subscriptions to system-wide events.

The intention is that clients can manage what topics they subscribe to via the web socket API or HTTP API.

Web Socket API

// subscribes to a specific topic
socket.emit( "subscription.add", { topic: "my.topic" } );

// subscribes to any topic beginning with `my`
socket.emit( "subscription.add", { topic: "my.#" } );

// unsubscribes to a topic
socket.emit( "subscription.remove", { topic: "my.topic" } );

HTTP API

This example demonstrates using a halon client to make the calls. (because hypermedia makes everything better)

var client = halon({
    root: "http://yourserver/api",
    adapter: halon.jQueryAdapter($)
});

client.subscription.add( { topic: "my.topic" } );

client.subscription.remove( { topic: "my.topic" } );

Installation & Setup

npm install autohost-pubsub -S
var autohost = require( "autohost" );
var host;
var hyped = require( "hyped" )();
var fount = require( "fount" );
var postal = require( "postal" );
// create the channel used to communicate between
// a message backbone/app and the pubsub resource
var channel = postal.channel( "ahpubsub" );

fount.register( "ahpubsub", channel );
host = hyped.createHost( autohost, {
	port: config.nonstop.host.port,
	modules: [
		"autohost-pubsub"
	],
	fount: fount
}, function() {
	host.start();
} );

// you can plug any message/event backbone into this system using the postal channel
// just publish events to the topics as the clients have subscribed to them
// and it will handle the rest ...

// this example demonstrates how you could forward messages from a rabbit
// queue via wascally and use the routing key of the message as the topic
rabbit.on( "some.important.message", function( message ) {
	channel.publish( message.fields.routingKey, message.body );
} );

Keywords

FAQs

Package last updated on 12 Nov 2015

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