0.8.11 • Published 4 months ago

@netpeer/swarm v0.8.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@netpeer/swarm

peer discoverer client & server

usage

server

import {Server} from '@netpeer/swarm'

const network = 'netpeer:peach'
const port = 44444

new Server(port, network)

client

import {Client} from '@netpeer/swarm'

const stars = ['wss://peach.netpeer.org']
const networkVersion = 'peach'
// wrtc object is added into glabalSpace
new Client(id, networkVersion, stars)

browser

import {Client} from '@netpeer/swarm/dist/client.browser.js'

// wrtc object is added into glabalSpace
new Client(id, networkVersion, stars)

examples

events

const client = new Client(id, networkVersion, stars)
// events exposed to pubsub
pubsub.subscribe('peer:data' data => console.log(data))
pubsub.subscribe('peer:joined', peer => console.log(peer))
pubsub.subscribe('peer:left', peer => console.log(peer))
pubsub.subscribe('peer:connected', peer => console.log(peer))
peernet.subscribe('shard', async message => console.log(message) // {id, data, size}
// const finished = await _handleMessage()

properties

const client = new Client(id, network)
client.id
client.connection
client.connections // object {id: connection}
0.8.11

4 months ago

0.8.10

4 months ago

0.8.9

4 months ago

0.8.8

4 months ago

0.8.5

4 months ago

0.7.6

4 months ago

0.8.4

4 months ago

0.8.7

4 months ago

0.8.6

4 months ago

0.8.1

4 months ago

0.8.0

4 months ago

0.8.3

4 months ago

0.8.2

4 months ago

0.7.5

4 months ago

0.7.4

4 months ago

0.7.3

4 months ago

0.7.2

4 months ago

0.7.1

4 months ago