-
Notifications
You must be signed in to change notification settings - Fork 1
/
ws_serv.py
31 lines (22 loc) · 831 Bytes
/
ws_serv.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
#!/usr/bin/python
from twisted.internet import reactor
from twisted.application import internet
from twisted.application.service import Application, Service
import txws
#from txws import WebSocketFactory
from WebSocketServerFactory import WebSocketServerFactory
class WebSocketService(Service):
def __init__(self):
pass
def start_service(self, application):
controlFactory = WebSocketServerFactory(self)
factory = txws.WebSocketFactory(controlFactory)
ws_server = internet.TCPServer(8080, factory)
ws_server.setName('ws-tcp')
ws_server.setServiceParent(application)
print "setup"
def shutdown(self):
reactor.callLater(0, reactor.stop)
application = Application("ws-streamer")
ws_service = WebSocketService()
ws_service.start_service(application)