def handle_server_connection(conn): """ Handle a client connection to the server """ print("connected to server") sc = SharedConnection(conn) sc.is_open = True # create a background thread here for receiving messages and show message sending ui in current thread background_thread = threading.Thread(target=handle_incoming_data, args=(sc, )) background_thread.start() # do gui related work here while sc.is_open: msg = input("send to server> ") sc.send(msg) if 'quit' == msg.strip().lower(): sc.close() background_thread.join()
def handle_client_connection(conn, addr): """ Handle a client connection """ print("Accepted connection from: " + repr(addr)) sc = SharedConnection(conn) sc.is_open = True # create a background thread here for receiving messages and show message sending ui in current thread background_thread = threading.Thread(target=handle_incoming_data, args=(sc, )) background_thread.start() # do gui related work here time.sleep(1) while sc.is_open: msg = input("send to client> ") sc.send(msg) if 'quit' == msg.strip().lower(): sc.close() background_thread.join()