summaryrefslogtreecommitdiff
path: root/CAO_Player.py
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2015-06-04 05:54:16 +0100
committerOlivier Gayot <duskcoder@gmail.com>2015-06-04 05:54:16 +0100
commit0cae8115a93589e37943590db45967beec841a07 (patch)
treead5bbecff01e42362d3670b90000fa77e9d38cc9 /CAO_Player.py
parent7d191b337b3114ceaa2ea69b538d3cd4f83bc094 (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.py11
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)