# libp2p-websocket-star-multi

> Allows to listen on multiple websocket-star-rendezvous servers while ignoring offline ones

Latest version **0.4.4** (published 2019-03-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install libp2p-websocket-star-multi
pnpm add libp2p-websocket-star-multi
yarn add libp2p-websocket-star-multi
bun add libp2p-websocket-star-multi
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.4.4 |
| Published | 2019-03-19 |
| First published | 2017-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 24.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Maciej Krüger |
| Maintainers | jacobheun, mkg20001 |
| Keywords | libp2p, websocket-star, round-robin, multiple |

## Links

- npm: https://www.npmjs.com/package/libp2p-websocket-star-multi
- Repository: https://github.com/mkg20001/js-libp2p-websocket-star-multi
- Homepage: https://github.com/mkg20001/js-libp2p-websocket-star-multi#readme
- Issues: https://github.com/mkg20001/js-libp2p-websocket-star-multi/issues
- npm.io page: https://npm.io/package/libp2p-websocket-star-multi

## Dependencies (6)

- [once](https://npm.io/package/once.md) ^1.4.0
- [async](https://npm.io/package/async.md) ^2.6.2
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [mafmt](https://npm.io/package/mafmt.md) ^6.0.7
- [multiaddr](https://npm.io/package/multiaddr.md) ^6.0.6
- [libp2p-websocket-star](https://npm.io/package/libp2p-websocket-star.md) ~0.10.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.4.4 (latest) — 2019-03-19
- 0.4.3 — 2019-01-24
- 0.4.0 — 2018-10-23
- 0.3.2 — 2018-02-12
- 0.3.1 — 2018-02-12
- 0.3.0 — 2017-12-07
- 0.2.1 — 2017-10-28
- 0.2.0 — 2017-09-26
- 0.1.1 — 2017-09-02
- 0.1.0 — 2017-08-31
- 0.0.1 — 2017-08-31

## README

# libp2p-websocket-star

[![](https://img.shields.io/badge/made%20by-mkg20001-blue.svg?style=flat-square)](http://ipn.io)
[![Build Status](https://travis-ci.org/libp2p/js-libp2p-websocket-star.svg?style=flat-square)](https://travis-ci.org/libp2p/js-libp2p-websocket-star)

![](https://raw.githubusercontent.com/libp2p/interface-connection/master/img/badge.png)
![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)

> Allows to listen on multiple websocket-star-rendezvous servers while ignoring offline ones

## Description

`libp2p-websocket-star-multi` allows to listen on multiple websocket-star-rendezvous servers while ignoring offline ones

**Note:** This module uses [pull-streams](https://pull-stream.github.io) for all stream based interfaces.

## Usage

### Installation

```bash
> npm install libp2p-websocket-star
```

### API

[![](https://raw.githubusercontent.com/libp2p/interface-transport/master/img/badge.png)](https://github.com/libp2p/interface-transport)

### Example

```js
'use strict'

const Libp2p = require('libp2p')
const Id = require('peer-id')
const Info = require('peer-info')
const multiaddr = require('multiaddr')
const pull = require('pull-stream')

const WSStarMulti = require('libp2p-websocket-star-multi')

Id.create((err, id) => {
  if (err) throw err

  const peerInfo = new Info(id)
  peerInfo.multiaddrs.add(multiaddr('/p2p-websocket-star')) // will get replaced to the multiaddr of the individual servers
  const ws = new WSStarMulti({
    servers: [ // servers are Multiaddr[]
      '/dnsaddr/ws-star-signal-1.servep2p.com/tcp/443/wss/p2p-websocket-star',
      '/dnsaddr/ws-star-signal-2.servep2p.com/tcp/443/wss/p2p-websocket-star',
      '/dnsaddr/ws-star-signal-3.servep2p.com/tcp/443/wss/p2p-websocket-star',
      '/dnsaddr/ws-star-signal-4.servep2p.com/tcp/443/wss/p2p-websocket-star',
      '/dnsaddr/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
      '/dns4/localhost/tcp/80/ws/p2p-websocket-star'
    ],
    // ignore_no_online: true, // enable this to prevent wstar-multi from returning a listen error if no servers are online
    id // the id is required for the crypto challenge
  })

  const modules = {
    transport: [
      ws
    ],
    discovery: [
      ws.discovery
    ]
  }

  const node = new Libp2p(modules, peerInfo)

  node.handle('/test/1.0.0', (protocol, conn) => {
    pull(
      pull.values(['hello']),
      conn,
      pull.map((s) => s.toString()),
      pull.log()
    )
  })

  node.start((err) => {
    if (err) {
      throw err
    }

    node.dial(peerInfo, '/test/1.0.0', (err, conn) => {
      if (err) {
        throw err
      }

      pull(
        pull.values(['hello from the other side']),
        conn,
        pull.map((s) => s.toString()),
        pull.log()
      )
    })
  })
})
```

Outputs:
```
hello
hello from the other side
```

### This module uses `pull-streams`

We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362).

You can learn more about pull-streams at:

- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ)
- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams)
- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple)
- [pull-streams documentation](https://pull-stream.github.io/)

#### Converting `pull-streams` to Node.js Streams

If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream`](https://github.com/pull-stream/pull-stream-to-stream), giving you an instance of a Node.js stream that is linked to the pull-stream. For example:

```js
const pullToStream = require('pull-stream-to-stream')

const nodeStreamInstance = pullToStream(pullStreamInstance)
// nodeStreamInstance is an instance of a Node.js Stream
```

To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream.

LICENSE MIT

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