Package Exports
- @web4/bitswarm-proxy-ws/client
- @web4/bitswarm-proxy-ws/client.js
- @web4/bitswarm-proxy-ws/server
- @web4/bitswarm-proxy-ws/server.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@web4/bitswarm-proxy-ws) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
bitswarm-proxy-ws
Proxy bitswarm connections over websockets with auto-reconnect logic
npm -s @web4/bitswarm-proxy-ws
Uses the bitswarm-proxy module.
Example
const BitswarmServer = require('@web4/bitswarm-proxy-ws/server')
// Initialize the proxy server
// Also specify any options for bitswarm here
// https://github.com/bitwebs/bitswarm
const server = new BitswarmServer()
// Start listening on clients via websocket protocol
server.listen(3472)
const BitswarmClient = require('@web4/bitswarm-proxy-ws/client')
// Initialize a proxied bitswarm
// Also specify any options for bitswarm-proxy client
// https://github.com/bitwebs/bitswarm-proxy#client
const swarm = new BitswarmClient({
// Specify a list of proxy servers available to connect to
proxy: ['ws://127.0.0.1:3472']
})
// Same as with bitswarm
swarm.on('connection', (connection, info) => {
const stream = getSomeStream(info.topic)
// Pipe the data somewhere
// E.G. bitdrive.replicate()
connection.pipe(stream).pipe(connection)
})
swarm.join(topic)
swarm.leave(topic)