Skip to content

Commit

Permalink
Add more debugging info
Browse files Browse the repository at this point in the history
  • Loading branch information
techno-sam committed May 3, 2021
1 parent 882cd55 commit 54cf18d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import colorsys

from colorama import Fore, Style

def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
default = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..'))
Expand Down Expand Up @@ -502,6 +504,9 @@ def circle_centered(screen, color, pos, radius, origin):
#print("successfull msg!")
if type(msg)==str:
msg = msg.encode()
unjsond = pickle.loads(msg)
if unjsond['mode']!=1:
debug(lambda:print(f"{Fore.LIGHTBLUE_EX}Received message from {HOST}:{PORT}: {unjsond}{Style.RESET_ALL}"))
inputQueue.put(pickle.loads(msg))
#End Get Incoming Communications

Expand Down
1 change: 1 addition & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ future==0.18.2
numpy==1.18.4
pyinstaller @ https://github.com/pyinstaller/pyinstaller/archive/master.zip
pygame==1.9.6
colorama
5 changes: 5 additions & 0 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import socketserver

from colorama import Fore, Style

'''thread use:
t = threading.Thread(target=function_for_thread_to_execute)
t.start() # thread ends when target returns
Expand Down Expand Up @@ -200,6 +202,8 @@ def handle(self):
else:
#handle the message...
unjsond = json.loads(msg)
if unjsond['mode']!=1:
debug(lambda:print(f"{Fore.LIGHTBLUE_EX}Received message from {self.client_address[0]}:{self.client_address[1]}: {unjsond}{Style.RESET_ALL}"))
if not 'mode' in unjsond.keys():
"""what the heck? what kind of communication is this supposed to be?"""
elif unjsond['mode']==0: #handshake
Expand Down Expand Up @@ -310,6 +314,7 @@ def add_seg_pos(head,segs):
try:
netstring.socksend(self.request,json.dumps(queued_message))
except TypeError:
add_to_out_queue(self.client_address[0],unjsond['cookie'],queued_message)
print(f"Failed to send a queued message to client: {self.client_address[0]}:{self.client_address[1]}, cookie: {unjsond['cookie']}")
queued_message = get_from_out_queue(self.client_address[0],unjsond['cookie'])

Expand Down

0 comments on commit 54cf18d

Please sign in to comment.