Skip to content

Commit

Permalink
immediately call callback if connection is in appropriate state
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Hoch committed Dec 19, 2023
1 parent 1b42530 commit 2a995be
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyvlx/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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."""
Expand Down

0 comments on commit 2a995be

Please sign in to comment.