diff --git a/pyvlx/connection.py b/pyvlx/connection.py index c0a5671e..1c3de6e8 100644 --- a/pyvlx/connection.py +++ b/pyvlx/connection.py @@ -131,6 +131,8 @@ def unregister_frame_received_cb(self, callback: CallbackType) -> None: def register_connection_closed_cb(self, callback: Callable[[], Coroutine]) -> None: """Register frame received callback.""" self.connection_closed_cbs.append(callback) + if not self.connected: + self.loop.create_task(callback) def unregister_connection_closed_cb(self, callback: Callable[[], Coroutine]) -> None: """Unregister frame received callback.""" @@ -139,6 +141,8 @@ def unregister_connection_closed_cb(self, callback: Callable[[], Coroutine]) -> def register_connection_opened_cb(self, callback: Callable[[], Coroutine]) -> None: """Register frame received callback.""" self.connection_opened_cbs.append(callback) + if self.connected: + self.loop.create_task(callback) def unregister_connection_opened_cb(self, callback: Callable[[], Coroutine]) -> None: """Unregister frame received callback."""