-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.py
48 lines (33 loc) · 1 KB
/
start.py
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
47
48
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from Synchronizer import Synchronizer
from Control import Control
from View import View
from twisted.python import log
from twisted.internet import task, reactor
from Networking import *
import sys
log.startLogging(sys.stdout)
ctl = Control()
syn = Synchronizer(ctl)
wsfactory = SydroidWebsocketFactory("ws://127.0.0.1:8007/", debug=True,
on_receive=lambda x: ctl.parse_line(x))
listenWS(wsfactory)
locfactory = SydroidLiquidsoapFactory(on_receive=lambda x: ctl.parse_line(x))
reactor.listenUNIX('/tmp/sydroid.sock', locfactory)
def send(mesg):
global wsfactory
if mesg["type"] == "status":
wsfactory.smart_broadcast(mesg)
else:
wsfactory.broadcast(json.dumps(mesg))
view = View(send)
ctl.sender = send
def main_loop():
syn.synchronize_all()
view.update_dradis()
if __name__ == '__main__':
print "Starting Sydroid."
l = task.LoopingCall(main_loop)
l.start(0.4)
reactor.run()