diff --git a/python/src/wslink/backends/aiohttp/__init__.py b/python/src/wslink/backends/aiohttp/__init__.py index 473b92d..ecde93d 100644 --- a/python/src/wslink/backends/aiohttp/__init__.py +++ b/python/src/wslink/backends/aiohttp/__init__.py @@ -35,10 +35,10 @@ def _fix_path(path): # ----------------------------------------------------------------------------- -class WebAppServer(AbstractWebApp, aiohttp_web.Application): +class WebAppServer(AbstractWebApp): def __init__(self, server_config): AbstractWebApp.__init__(self, server_config) - aiohttp_web.Application.__init__(self) + self.set_app(aiohttp_web.Application()) self._ws_handlers = [] self._site = None self._runner = None @@ -52,7 +52,7 @@ def __init__(self, server_config): aiohttp_web.get(_fix_path(route), protocol_handler.handleWsRequest) ) - self.add_routes(routes) + self.app.add_routes(routes) if "static" in server_config: static_routes = server_config["static"] @@ -68,10 +68,10 @@ def __init__(self, server_config): ) # Resolve / => index.html - self.router.add_route("GET", "/", _root_handler) - self.add_routes(routes) + self.app.router.add_route("GET", "/", _root_handler) + self.app.add_routes(routes) - self["state"] = {} + self.app["state"] = {} # ------------------------------------------------------------------------- # Server status @@ -94,7 +94,9 @@ def get_port(self): # ------------------------------------------------------------------------- async def start(self, port_callback=None): - self._runner = aiohttp_web.AppRunner(self, handle_signals=self.handle_signals) + self._runner = aiohttp_web.AppRunner( + self.app, handle_signals=self.handle_signals + ) logging.info("awaiting runner setup") await self._runner.setup() diff --git a/python/src/wslink/protocol.py b/python/src/wslink/protocol.py index 6c71fca..027a1f3 100644 --- a/python/src/wslink/protocol.py +++ b/python/src/wslink/protocol.py @@ -16,6 +16,7 @@ def __init__(self, server_config): self._config = server_config self._shutdown_task = None self._completion = asyncio.get_event_loop().create_future() + self._app = None # ------------------------------------------------------------------------- # Config helper @@ -58,11 +59,22 @@ def last_active_client_id(self, value): self._last_active_client_id = value # ------------------------------------------------------------------------- - # Legacy / deprecated + # Implementation server class # ------------------------------------------------------------------------- - def set_app(self, *args): - print("DEPRECATED: set_app()") + def set_app(self, app): + self._app = app + + def get_app(self): + return self._app + + @property + def app(self): + return self._app + + # ------------------------------------------------------------------------- + # Legacy / deprecated + # ------------------------------------------------------------------------- def get_config(self): print("DEPRECATED: get_config() use property instead") @@ -71,14 +83,6 @@ def get_config(self): def set_config(self, config): print("DEPRECATED: set_config() use constructor instead") - def get_app(self): - print("DEPRECATED: get_app()") - return self - - @property - def app(self): - print("DEPRECATED: .app.") - def get_last_active_client_id(self): print( "DEPRECATED: get_last_active_client_id() should be replaced by last_active_client_id"