-
Notifications
You must be signed in to change notification settings - Fork 0
/
thdemo.coffee
46 lines (35 loc) · 935 Bytes
/
thdemo.coffee
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
40
41
42
43
44
45
46
[API, _, IO] =
[exports._app = {},
(require 'lodash'),
(require 'socket.io')]
___ = (x)->console.log x
control_socket = null
video_socket = null
on_select = (d) ->
___ "select #{d}"
video_socket?.emit 'select', d
on_controls = (d) ->
___ "controls #{d}"
video_socket?.emit 'controls', d
on_seek = (d) ->
___ "seek #{d}"
video_socket?.emit 'seek', d
on_speed = (d) ->
___ "speed #{d}"
video_socket?.emit 'speed', d
on_pause = ->
___ 'pause'
video_socket?.emit 'pause'
API.SIO = (parseInt process.argv[2]) or 4567
IO = IO.listen API.SIO, 'log level': 1
IO.sockets.on 'connection', (s) ->
___ "connected #{s.id}"
s.on 'message', (d) -> ___ "got #{d}"
s.on 'control', -> control_socket = s
s.on 'video', -> video_socket = s
s.on 'select', on_select
s.on 'controls', on_controls
s.on 'seek', on_seek
s.on 'speed', on_speed
s.on 'pause', on_pause
___ "socket.io listening on #{API.SIO}"