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()) })
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, ())
def PenDown(self, e): connection.send({"action": "startline", "point": e.pos})
def PenUp(self, e): connection.send({"action": "drawpoint", "point": e.pos})
def Network_ping(self, data): print("got:", data) if data["count"] == 10: connection.close() else: connection.send(data)