def new_client(conn): handle_client_handshake.handle_client_handshake(conn) while True: file_name_recv = conn.recv(4096) if file_name_recv: decoded_data = decode_data.decode_data(file_name_recv) # print decoded_data file_name = decoded_data.replace('Create file:', '') # print file_name send_file(file_name)
def new_client(conn, addr, clients_set, files_mapping): clients_set.add(conn) handle_client_handshake.handle_client_handshake(conn) thread.start_new_thread(send_file_string, (clients_set,)) while 1: print 'Calling file send' data_recv = conn.recv(4096) if not data_recv: break data_from_client = decode_data.decode_data(data_recv) if ".txt" in data_from_client: open_file_name = store_mapping_and_send_file_data(conn, data_from_client, files_mapping) else: save_to_file(data_from_client, open_file_name) send_updated_file(data_from_client, open_file_name, clients_set, files_mapping)
import modules.create_socket as create_socket import modules.handle_client_handshake as handle_client_handshake import modules.decode_data as decode_data import modules.lib.diff_match_patch as dmp_module HOST = '' PORT = 9205 if __name__ == "__main__": s = create_socket.start_server(HOST, PORT) dmp = dmp_module.diff_match_patch() while True: conn, addr = s.accept() handle_client_handshake.handle_client_handshake(conn) data_recv = conn.recv(4096) if not data_recv: break data_from_client = decode_data.decode_data(data_recv) patch = dmp.patch_fromText(data_from_client) result = dmp.patch_apply(patch, '') print result[0]