-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.pug
32 lines (26 loc) · 808 Bytes
/
home.pug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
script(src="http://cdn.peerjs.com/0.3/peer.js")
script.
var count = "#{count}";
var prevCount = "#{prevCount}";
console.log(count);
//- "Join" pool of peers.
var peer = new Peer(count, {host: "localhost", port: 9000, path: "/api"});
//- Accept incoming connections.
//- "Listen to your friend!"
peer.on("connection", function(conn) {
conn.on("data", function(data){
//- "Print what your friend said."
console.log(data);
});
});
//- Send outgoing connection if we have one.
//- "Tell your friend!"
if (prevCount !== "") {
var conn = peer.connect(prevCount);
conn.on("open", function(){
//- "Tell your friend your name!"
conn.send("hi, my name is " + count + "!");
});
}
.carson Hello, #{count}.
.carson Your friend is, #{prevCount}.