-
Notifications
You must be signed in to change notification settings - Fork 26
/
index.js
39 lines (30 loc) · 919 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
33
34
35
36
37
38
39
var choo = require('choo')
var app = choo()
app.use(function (state, emitter) {
state.broadcast = {}
state.broadcast.active = false
state.broadcast.key = null
state.broadcast.audioOnly = false
emitter.on('audioOnlyToggle', function() {
state.broadcast.audioOnly = !state.broadcast.audioOnly
emitter.emit('render')
})
emitter.on('broadcast:start', function (key) {
state.broadcast.peerCount = 0
state.broadcast.active = true
state.broadcast.key = key
emitter.emit('render')
})
emitter.on('broadcast:peer', function (peerCount) {
state.broadcast.peerCount = peerCount
emitter.emit('render')
})
emitter.on('broadcast:stop', function (key) {
state.broadcast.peerCount = 0
state.broadcast.active = false
state.broadcast.key = null
emitter.emit('render')
})
})
app.route('/', require('./templates/home'))
document.body.appendChild(app.start())