0.2.17 • Published 5 years ago

@wirelineio/discovery-swarm-memory v0.2.17

Weekly downloads
105
License
GPL-3.0
Repository
github
Last release
5 years ago

Wireline Discovery Swarm Memory

Description

A minimal implementation of the discovery-swarm to simulate and test multiple connections in memory.

Usage

Example

import swarm from '@wirelineio/discovery-swarm-memory';

const sw = swarm();

sw.listen(1000)
sw.join('ubuntu-14.04') // can be any id/name/hash

sw.on('connection', function (connection) {
  console.log('found + connected to peer')
})

API

var sw = swarm(opts)

Create a new swarm. Options include:

{
  id: crypto.randomBytes(32), // peer-id for user
  stream: stream // stream to replicate across peers
}

sw.join(key, [opts], [cb])

Join a channel specified by key (usually a name, hash or id, must be a Buffer or a string). After joining will immediately search for peers advertising this key.

sw.leave(key)

Leave the channel specified key

sw.on('connection', function(connection, info) { ... })

Emitted when you have fully connected to another peer. Info is an object that contains info about the connection.

info

{
  initiator: true, // whether we initiated the connection or someone else did.
  channel: Buffer('...'), // the channel this connection was initiated on. only set if initiator === true.
  id: Buffer('...') // the remote peer's peer-id.
}

sw.on('connection-closed', function(connection, info) { ... })

Emitted when you've disconnected from a peer. Info is an object that contains info about the connection.

sw.listen(port)

Listen on a specific port. Should be called before join

0.2.17

5 years ago

0.2.16

5 years ago

0.2.15

5 years ago

0.2.14

5 years ago

0.2.12

5 years ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.9-beta.2

5 years ago

0.2.9-beta.1

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.2.0-alpha.2

5 years ago

0.2.0-alpha.1

5 years ago

0.2.0-alpha.0

5 years ago

0.1.36

5 years ago

0.1.35

5 years ago

0.1.34

5 years ago

0.1.33

5 years ago

0.1.21

5 years ago

0.1.18

5 years ago

0.1.14

5 years ago