def send_cancel_query(sock, cmd_id): cancel_query_mes = CommandMessage() cancel_query_mes.type = CommandMessage.CANCEL_QUERY cancel_query_mes.cmdId = cmd_id cancel_query_mes_as_string = cancel_query_mes.SerializeToString() sock.sendall(struct.pack('I', len(cancel_query_mes_as_string))) sock.sendall(cancel_query_mes_as_string)
def send_new_query(sock, query): global last_id mes = CommandMessage() mes.type = CommandMessage.NEW_QUERY mes.cmdId = last_id last_id += 1 mes.newQuery.query = query new_query_mes_as_string = mes.SerializeToString() sock.sendall(struct.pack('I', len(new_query_mes_as_string))) sock.sendall(new_query_mes_as_string) return mes.cmdId