-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.coffee
More file actions
32 lines (22 loc) · 805 Bytes
/
index.coffee
File metadata and controls
32 lines (22 loc) · 805 Bytes
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
fs = require('fs')
coffee = require('coffee-script')
firefly_client_source = fs.readFileSync(__dirname + '/lib/firefly-client.coffee').toString()
firefly_client_source_compiled = coffee.compile(firefly_client_source)
port = Number(process.env.PORT || 80)
require('zappa') port, ->
@get '/js/firefly.js': ->
@send(firefly_client_source_compiled)
@on 'connection': ->
@broadcast 'entry cursor', { @id }
@on 'mouse position': ->
@broadcast 'move cursor', { @id, screen: @data }
@on 'disconnect': ->
@broadcast 'disconnect', { @id }
clientCount = 0
@on 'connection': ->
clientCount += 1
@broadcast 'change count', { clientCount }
@emit 'change count', { clientCount }
@on 'disconnect': ->
clientCount -= 1
@broadcast 'change count', { clientCount }