peer-channel
v0.1.2
Published
create and connect to servers by name
Downloads
5
Readme
peer-channel
create and connect to servers by name, in node or the browser.
$ npm install peer-channel
Usage
First create a server
let { createServer } = require('peer-channel')
let server = createServer(function(conn) {
conn.on('data', function(data) {
console.log(data.toString())
})
conn.send('hello from the server')
})
server.listen('abc123')
// server.close() to gracefully shut down the server
then connect to it like:
let { connect } = require('peer-channel')
let pc = connect('abc123')
pc.on('connect', function(conn) {
conn.on('data', function(data) {
console.log(data.toString())
})
conn.send('hello from the client')
})
// pc.close()