-
Notifications
You must be signed in to change notification settings - Fork 0
/
MessageReceiver.py
34 lines (27 loc) · 1.11 KB
/
MessageReceiver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
from threading import Thread
from MessageParser import MessageParser
class MessageReceiver(Thread):
"""
This is the message receiver class. The class inherits Thread, something that
is necessary to make the MessageReceiver start a new thread, and it allows
the chat client to both send and receive messages at the same time
"""
def __init__(self, client, connection):
"""
This method is executed when creating a new MessageReceiver object
"""
# Flag to run thread as a deamon
#self.client=client
self.connection = connection
# tODO: Finish initialization of MessageReceiver
super(MessageReceiver,self).__init__()
def run(self):
# tODO: Make MessageReceiver receive and handle payloads
self.MessageParser = MessageParser()
#s_thread = MessageParser(payload)
#s_thread.start()
while True:
payload = self.connection.recv(4096)
#print('We now listening for input from server.' + payload)
self.MessageParser.parse(payload)