diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-06-04 05:54:16 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-06-04 05:54:16 +0100 |
commit | 0cae8115a93589e37943590db45967beec841a07 (patch) | |
tree | ad5bbecff01e42362d3670b90000fa77e9d38cc9 /CAO_Player.py | |
parent | 7d191b337b3114ceaa2ea69b538d3cd4f83bc094 (diff) |
added a system of notification
what the client will receive will look like:
{'type': TYPE, 'content': CONTENT}
TYPE will be either 'notification' or 'response'
CONTENT will be the content of the notification or the response
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'CAO_Player.py')
-rw-r--r-- | CAO_Player.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/CAO_Player.py b/CAO_Player.py index 94ff2cf..a4dc326 100644 --- a/CAO_Player.py +++ b/CAO_Player.py @@ -1,3 +1,5 @@ +import json + class CAO_Player(): def __init__(self, client): self.cards = {} @@ -14,7 +16,6 @@ class CAO_Player(): def pop_card(self, card_id): return self.cards.pop(card_id) - def get_has_played(self): return self.has_played @@ -27,3 +28,11 @@ class CAO_Player(): def receive_card(self, card): self.cards[self.next_idx] = card self.next_idx += 1 + + def send_notification(self, obj): + if self.client is None: + return + + message = json.dumps({'type': 'notification', 'content': obj}) + + self.client.send_notification(message) |