-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
32 lines (26 loc) · 949 Bytes
/
index.js
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
var boot = require("boot")
, mdm = boot("/stream/boot")
, es = require("event-stream")
, through = require("through")
, body = window.document.body
var roomDiv = document.createElement("div")
, roomJoinBar = document.createElement("div")
, titleBar = document.createElement("div")
var renderTitleAndLink = require("./titleAndLink")
, renderJoinRoom = require("./joinRoom")
, renderRoom = require("./room")
var room = renderJoinRoom(roomJoinBar)
room.on("join", function (roomName, userName) {
var dataStream = mdm.createStream("/room/" + roomName)
dataStream.on("data", function (d) {
console.log("data", JSON.parse(d))
})
// Empty roomDiv
roomDiv.textContent = ""
var uiStream = renderRoom(roomDiv, roomName, userName)
uiStream.pipe(dataStream).pipe(uiStream)
})
renderTitleAndLink(titleBar)
body.appendChild(titleBar)
body.appendChild(roomDiv)
body.appendChild(roomJoinBar)