summaryrefslogtreecommitdiff
path: root/swiftstory/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'swiftstory/client.py')
-rw-r--r--swiftstory/client.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/swiftstory/client.py b/swiftstory/client.py
index 527c9c6..c3a2aff 100644
--- a/swiftstory/client.py
+++ b/swiftstory/client.py
@@ -66,12 +66,16 @@ class Client:
raise WrongAction('You have to join a game first')
return self.game.try_view_black_card(self.player)
- def register_notification(self, message):
+ def monitor_player(self) -> None:
+ """ Start monitoring the player for notifications and send them. """
async def f():
- try:
- await self.socket.send(message)
- except websockets.exceptions.ConnectionClosed:
- logging.warning("Recipient has disconnected.")
+ assert self.player is not None
+ while True:
+ try:
+ notif = await self.player.notifications.get()
+ await self.socket.send(notif)
+ except websockets.exceptions.ConnectionClosed:
+ logging.warning("Recipient has disconnected.")
asyncio.create_task(f())