[MerlinSkinThemes] - add support for layouts
[enigma2-plugins.git] / webinterface / src / WebSocket / DreamboxWebSocketServer.py
1 from DreamboxServerProtocol import DreamboxServerProtocol
2
3 from autobahn.twisted.websocket import WebSocketServerFactory
4 from autobahn.twisted.resource import WebSocketResource
5
6 class DreamboxWebSocketServer():
7         def __init__(self):
8                 self.session = None
9                 self._sessions = set()
10                 self._factory = WebSocketServerFactory(url=None, debug=False, debugCodePaths=False)
11                 self._factory.setProtocolOptions(autoPingInterval=15, autoPingTimeout=3)
12                 self._factory.protocol = DreamboxServerProtocol
13                 self.root = WebSocketResource(self._factory)
14                 DreamboxServerProtocol.server = None
15
16         def addSession(self, session):
17                 self._sessions.add(session)
18
19         def removeSession(self, session):
20                 self._sessions.remove(session)
21
22         def checkSession(self, session):
23                 return session in self._sessions
24
25         def start(self, session):
26                 self._session = session
27                 #protocol
28                 DreamboxServerProtocol.server = self
29                 DreamboxServerProtocol.session = session
30
31 webSocketServer = DreamboxWebSocketServer()