class WebSocketBackend(BackendBase): def setup(self, host, port): from wsbackend.Server import WebSocketServer, DefaultOptions from wsbackend.Dispatcher import Dispatcher from wsbackend.ApiHandler import ApiHandler from wsbackend.AsyncHandler import AsyncHandler options = DefaultOptions() options.server_host = host options.port = port options.dispatcher = Dispatcher() options.dispatcher.addHandler(ApiHandler.PATH, ApiHandler(self.core.api)) options.dispatcher.addHandler(AsyncHandler.PATH, AsyncHandler(self.core.api)) # tls is needed when requested or webUI is also on tls if self.core.api.isWSSecure(): from wsbackend.Server import import_ssl tls_module = import_ssl() if tls_module: options.use_tls = True options.tls_module = tls_module options.certificate = self.core.config['ssl']['cert'] options.private_key = self.core.config['ssl']['key'] self.core.log.info(_('Using secure WebSocket')) else: self.core.log.warning(_('SSL could not be imported')) self.server = WebSocketServer(options) def serve(self): self.server.serve_forever()
def setup(self, host, port): from wsbackend.Server import WebSocketServer, DefaultOptions from wsbackend.Dispatcher import Dispatcher from wsbackend.ApiHandler import ApiHandler from wsbackend.AsyncHandler import AsyncHandler options = DefaultOptions() options.server_host = host options.port = port options.dispatcher = Dispatcher() options.dispatcher.addHandler(ApiHandler.PATH, ApiHandler(self.core.api)) options.dispatcher.addHandler(AsyncHandler.PATH, AsyncHandler(self.core.api)) self.server = WebSocketServer(options)
class WebSocketBackend(BackendBase): def setup(self, host, port): from wsbackend.Server import WebSocketServer, DefaultOptions from wsbackend.Dispatcher import Dispatcher from wsbackend.ApiHandler import ApiHandler from wsbackend.AsyncHandler import AsyncHandler options = DefaultOptions() options.server_host = host options.port = port options.dispatcher = Dispatcher() options.dispatcher.addHandler(ApiHandler.PATH, ApiHandler(self.core.api)) options.dispatcher.addHandler(AsyncHandler.PATH, AsyncHandler(self.core.api)) self.server = WebSocketServer(options) def serve(self): self.server.serve_forever()