Permalink
Browse files

docs

  • Loading branch information...
1 parent 41a78d0 commit b274f4070408ede92d68ba038704af07cc1711da @Raynos committed Dec 12, 2012
Showing with 35 additions and 1 deletion.
  1. +35 −1 README.md
View
@@ -5,7 +5,41 @@ network of peer connections
## Example
```js
-COMING SOON
+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

0 comments on commit b274f40

Please sign in to comment.