예제 #1
0
 def InputLoop(self):
     # horrid threaded input loop
     # continually reads from stdin and sends whatever is typed to the server
     while 1:
         connection.send({
             "action": "message",
             "message": stdin.readline().rstrip("\n".encode())
         })
예제 #2
0
 def __init__(self, host, port):
     self.connect((host, port))
     print("Chat client started")
     print("Ctrl-C to exit")
     # get a nickname from the user before starting
     print("Enter your nickname: ")
     connection.send({
         "action": "nickname",
         "nickname": stdin.readline().rstrip("\n")
     })
     # launch our threaded input loop
     t = start_new_thread(self.InputLoop, ())
예제 #3
0
 def PenDown(self, e):
     connection.send({"action": "startline", "point": e.pos})
예제 #4
0
 def PenUp(self, e):
     connection.send({"action": "drawpoint", "point": e.pos})
예제 #5
0
 def Network_ping(self, data):
     print("got:", data)
     if data["count"] == 10:
         connection.close()
     else:
         connection.send(data)