0.1.2 • Published 5 years ago

peer-channel v0.1.2

Weekly downloads
6
License
ISC
Repository
-
Last release
5 years ago

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()