diff options
| author | Tom Harley | 2017-12-02 19:43:36 +0000 |
|---|---|---|
| committer | Tom Harley | 2017-12-02 19:43:36 +0000 |
| commit | ca904d5d25e03398aa76db329e086935f1cfab75 (patch) | |
| tree | b89928cdcf89705f1e8a8b3741fdb7fbd7a04973 /client/client.py | |
| parent | Can quit the game at any time (diff) | |
| download | longpong-ca904d5d25e03398aa76db329e086935f1cfab75.tar.gz longpong-ca904d5d25e03398aa76db329e086935f1cfab75.zip | |
yes
Diffstat (limited to 'client/client.py')
| -rw-r--r-- | client/client.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/client/client.py b/client/client.py index 3da7a3a..7dec01e 100644 --- a/client/client.py +++ b/client/client.py @@ -15,18 +15,19 @@ class Client: def listen(self): try: msg = self.sock.recv(4096) - jsonMSG = json.loads(msg) + jsonMSG = json.loads(msg.decode()) print(jsonMSG) - if 'command' in data: + if 'command' in jsonMSG: val = jsonMSG['command'] if val == 'start': self.started = True self.startupMessage = jsonMSG + self.msgs.append(jsonMSG) elif val =='stop': self.stopped = True self.stoppedMessage = jsonMSG else: - msgs.append(jsonMSG) + self.msgs.append(jsonMSG) else: print("It really shouldn't be here") @@ -36,11 +37,14 @@ class Client: def get_messages(self): ret = self.msgs[:] self.msgs = [] + return ret def send_init(self,screen): inp = {} - inp['nValue'] = self.n; - inp['screenSize'] = str(screen) + inp['info'] = { + "scr_i": self.n, + "scr_w": screen + } self.sock.sendall(str(json.dumps(inp)).encode()) def send_start(self): |
