Conditions | 2 |
Total Lines | 14 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import errno |
||
25 | def retrieve_next_message(self, new_messages): |
||
26 | username_header = self.socket.recv(HEADER_LENGTH) |
||
27 | if not len(username_header): |
||
28 | print("Connection closed by the server") |
||
29 | sys.exit() |
||
30 | |||
31 | username_length = int(username_header.decode("utf-8").strip()) |
||
32 | username = self.socket.recv(username_length).decode("utf-8") |
||
33 | |||
34 | message_header = self.socket.recv(HEADER_LENGTH) |
||
35 | message_length = int(message_header.decode("utf-8").strip()) |
||
36 | message = self.socket.recv(message_length).decode("utf-8") |
||
37 | |||
38 | new_messages.append({'author': username, 'content': message}) |
||
39 | |||
57 |