Skip to content
Permalink
Browse files

FIX USER NOT ANSWERING FOR 3 TIMES, added change cursor on link

  • Loading branch information
mateussa committed Nov 22, 2017
1 parent 2a00d03 commit 159804397235ff1f70df225198397ae6cde6de54
Showing with 14 additions and 13 deletions.
  1. +13 −12 Server.py
  2. +1 −1 tkHyperlinkManager.py
@@ -8,24 +8,24 @@ def sendMessage(message, EOM = True): # Andre
''' Given a message input, and a False value, send the message and the
client keeps wayting for another message '''
resp = ""
while (resp != "Received"): # If client doesn't receive message, send again
conn.send(str(message).encode())
print("SERVER: {}".format(message))
resp = conn.recv(1024).decode() # Waits for client feedback
if (EOM):
conn.send("EndOfMessage".encode())
while (resp != "Received"): # Check if the client received the message.
conn.send(str(message).encode()) # Send message to client.
print("SERVER: {}".format(message)) # Print the message sent.
resp = conn.recv(1024).decode() # Waits for client feedback
if (EOM): # If this is the last message to be sent
conn.send("EndOfMessage".encode()) # Send a key word to the client to stop listening

def receiveMessage(): # Andre
''' Receive a message from the client and check if received correctly,
returns the message '''
message = conn.recv(1024).decode()
if not message: # If message is None, try to receive again
if not message: # If message is empty, try to receive again
sendMessage("Sorry, I couldn't get that, can you repeat?")
message = conn.recv(1024).decode()
if not message: # Couldn't receive message, exit
if not message: # If message is empty again, send message and exit
sendMessage("Sorry, I not able to receive that, plese try again another day.")
exit()
print(message)
if (message != "END"):
print ("CLIENT: {}".format(message))

@@ -56,15 +56,16 @@ def askSomething(answerType, sendMessages, noAnswers, defaultAnswer): # Andre
break
break

if (answer[1] == 2): # If the user asked a how or are question
if (answer[1] == 2): # If the user asked a question
if (type(answer[0]) == str):
sendMessage(answer[0], False)
else:
sendMessage(answer[0][0], False)
sendMessage(answer[0][1], False)

sendMessage(noAnswers[0])
noAnswers.pop(0)
sendMessage(noAnswers[0]) # FIX WHEN THE USER DOENS ANSWER FOR 3 TIMES
if (len(noAnswers) > 0):
noAnswers.pop(0)
elif (answer[1] == 5): # If the user doesn't want to answer
sendMessage("You should, it would be more fun!")
noAnswers.pop(len(noAnswers) - 1)
@@ -14,7 +14,7 @@ def __init__(self, text):

self.text.tag_config("hyper", foreground="blue", underline=1)

#self.text.tag_bind("hyper", "<Enter>", self._enter) #Removed to prevent conflict with pressing Enter to send a message
self.text.tag_bind("hyper", "<Enter>", self._enter) #Removed to prevent conflict with pressing Enter to send a message
self.text.tag_bind("hyper", "<Leave>", self._leave)
self.text.tag_bind("hyper", "<Button-1>", self._click)

0 comments on commit 1598043

Please sign in to comment.
You can’t perform that action at this time.