LoopBack 3 has reached end of life. We are no longer accepting pull requests or providing support for community users. The only exception is fixes for critical bugs and security vulnerabilities provided as part of support for IBM API Connect customers. We urge all LoopBack 3 users to migrate their applications to LoopBack 4 as soon as possible. Learn more about LoopBack's long term support policy.

Node pub-sub example app

Page Contents
Note: This page was generated from the strong-pubsub-example/README.md.

Strong PubSub Example

This example demonstrates the end-to-end functionality of the strong-pubsub modules.

  • Publishing (from a node.js CLI program)
  • Subscribing (from a browser and node.js CLI program)
  • Bridge connections (from the browser or TCP)
  • Browserify + Primus (for use in browsers)

Prerequisites

  1. Install Mosquitto
  2. Make sure that the path to the Mosquito executable is on your system PATH. For example, on Mac OS, you might need to add /usr/local/sbin to your PATH.

Run the example

To run:

$ git clone https://github.com/strongloop/strong-pubsub-example.git
$ cd strong-pubsub-example
$ npm install
$ node server.js

To subscribe:

# open http://localhost:3000 in a browser
# and open the browser's console
# note: the browser client will subscribe to the topic "foo"
# subscribe directly to mosquitto
$ TOPIC=foo PORT=6000 node sub
# subscribe to the TCP bridge
$ TOPIC=foo PORT=3000 node sub

To publish a message:

# publish directly to mosquitto
$ TOPIC=foo PORT=6000 node pub
# publish to the TCP bridge
$ TOPIC=foo PORT=3000 node pub

AltStyle によって変換されたページ (->オリジナル) /