Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 53 lines (36 sloc) 1.048 kb

peer-connection-network

network of peer connections

Example

var relay = require("signal-channel/relay")
    , PeerConnectionShim = require("peer-connection-shim")

    , Network = require("peer-connection-network")

var net1 = Network(createPeerConnection)
    , net2 = Network(createPeerConnection)

var stream1 = net1.createStream()
    , stream2 = net2.createStream()

stream1.pipe(stream2).pipe(stream1)

net1.listen("foo")
net2.listen("bar")

net2.on("connection", function (pc) {
    var stream = pc.createStream("foo")
    stream.write("hello world")
})

var pc = net1.connect("bar")
pc.on("connection", function (stream) {
    stream.on("data", function (chunk) {
        console.log("data", String(chunk))
    })
})

// Use the peer connect shim which requires a relay server connection
function createPeerConnection() {
    return PeerConnectionShim({
        stream: relay("peer-connection-network example")
    })
}

Installation

npm install peer-connection-network

Contributors

  • Raynos

MIT Licenced

Something went wrong with that request. Please try again.