# signalhub

> Simple signalling server that can be used to coordinate handshaking with webrtc or other fun stuff.

Latest version **4.9.0** (published 2017-09-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install signalhub
pnpm add signalhub
yarn add signalhub
bun add signalhub
```

Provides the command `signalhub`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.9.0 |
| Published | 2017-09-28 |
| First published | 2015-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 11 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 672 |
| Author | Mathias Buus |
| Maintainers | mafintosh, maxogden, feross |

## Links

- npm: https://www.npmjs.com/package/signalhub
- Repository: https://github.com/mafintosh/signalhub
- Issues: https://github.com/mafintosh/signalhub/issues
- npm.io page: https://npm.io/package/signalhub

## Dependencies (11)

- [nets](https://npm.io/package/nets.md) ^3.1.0
- [pump](https://npm.io/package/pump.md) ^1.0.0
- [corsify](https://npm.io/package/corsify.md) ^2.1.0
- [inherits](https://npm.io/package/inherits.md) ^2.0.1
- [minimist](https://npm.io/package/minimist.md) ^1.1.1
- [through2](https://npm.io/package/through2.md) ^0.6.5
- [end-of-stream](https://npm.io/package/end-of-stream.md) ^1.1.0
- [random-iterate](https://npm.io/package/random-iterate.md) ^1.0.1
- [stream-collector](https://npm.io/package/stream-collector.md) ^1.0.1
- [size-limit-stream](https://npm.io/package/size-limit-stream.md) ^1.0.0
- [event-source-stream](https://npm.io/package/event-source-stream.md) ^1.3.1

## Recent versions

- 4.9.0 (latest) — 2017-09-28
- 4.8.0 — 2016-11-22
- 4.7.4 — 2016-06-24
- 4.7.3 — 2016-06-24
- 4.7.2 — 2016-06-24
- 4.7.1 — 2016-06-23
- 4.7.0 — 2016-06-23
- 4.6.0 — 2016-06-15
- 4.5.1 — 2016-06-08
- 4.5.0 — 2016-06-07
- 4.4.0 — 2016-05-28
- 4.3.2 — 2016-02-05
- 4.3.1 — 2015-09-20
- 4.3.0 — 2015-09-11
- 4.2.2 — 2015-08-30
- … 21 more at https://npm.io/package/signalhub/versions

## README

# signalhub

Simple signalling server that can be used to coordinate handshaking with webrtc or other fun stuff.

```
npm install signalhub
```

Or to install the command line tool

```
npm install -g signalhub
```

[![build status](http://img.shields.io/travis/mafintosh/signalhub.svg?style=flat)](http://travis-ci.org/mafintosh/signalhub)

## Usage

``` js
var signalhub = require('signalhub')
var hub = signalhub('my-app-name', [
  'http://yourhub.com'
])

hub.subscribe('my-channel')
  .on('data', function (message) {
    console.log('new message received', message)
  })

hub.broadcast('my-channel', {hello: 'world'})
```

## API

#### `hub = signalhub(appName, urls)`

Create a new hub client. If you have more than one hub running specify them in an array

``` js
// use more than one server for redundancy
var hub = signalhub('my-app-name', [
  'https://signalhub1.example.com',
  'https://signalhub2.example.com',
  'https://signalhub3.example.com'
])
```

The `appName` is used to namespace the subscriptions/broadcast so you can reuse the
signalhub for more than one app.

#### `stream = hub.subscribe(channel)`

Subscribe to a channel on the hub. Returns a readable stream of messages

#### `hub.broadcast(channel, message, [callback])`

Broadcast a new message to a channel on the hub

#### `hub.close([callback])`

Close all subscriptions

## CLI API

You can use the command line api to run a hub server

```
signalhub listen -p 8080 # starts a signalhub server on 8080
```

To listen on https, use the `--key` and `--cert` flags to specify the path to the private
key and certificate files, respectively. These will be passed through to the node `https`
package.

To avoid logging to console on every subscribe/broadcast event use the `--quiet` or `-q` flag.

Or broadcast/subscribe to channels

```
signalhub broadcast my-app my-channel '{"hello":"world"}' -p 8080 -h yourhub.com
signalhub subscribe my-app my-channel -p 8080 -h yourhub.com
```

## Browserify

This also works in the browser using browserify :)

## Deploying with popular services

No additional configuration is needed.

### now.sh

```
now mafintosh/signalhub
```

### Heroku
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)

## License

MIT

---
_Source: https://npm.io/package/signalhub · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
