def main(): """ Command Line Interface entry point :return: None """ Client()
def setUp(self): global g_count self.count = g_count g_count += 1 self.req_q = SQS("{}-{}".format(test_req_q, self.count)) self.in_b = S3("{}-{}".format(test_in_b, self.count)) self.out_b = S3("{}-{}".format(test_out_b, self.count)) self.cli = Client("{}-{}".format(test_res_q, self.count), "{}-{}".format(test_req_q, self.count), "{}-{}".format(test_in_b, self.count))
def main() -> None: def onMessage(msg: Message) -> None: global recvSomething print(f'[{msg.author}]: {msg.content}') recvSomething += 1 global recvSomething with Client() as client: client.setCloseListener(lambda: print(' - closed')) client.setMessageListener(onMessage) print(' - connecting...') client.setAddress('127.0.0.1', 20307) client.setUsername('PythonTest') print(' - waiting for response...') while recvSomething != 2: pass
def startLogin(self): username = self.getUsername() host = self.getHost() port = self.getPort() try: self.client = Client(username, host, port) self.windowChat = WindowChat(username) # Username is empty or somethings isConnectionFail = self.client.connectToServer() if isConnectionFail: self.dialogChangeUsername() # else: # self.windowChat.setupFriendsList(self.client.peerList) # Track changeing Friend List self.client.change_friend_list.connect(self.windowChat.setupFriendsList) self.client.start() self.windowChat.show() self.close() except: self.showMessageBox("Error", "Can't connect to server %s:%d" % (host, port))
def main(): args = parse() print(args) print(args.list) input_file = args.input_file cli_q_name = args.cli_q srv_q_name = args.srv_q srv_b_name = args.srv_b is_file = args.file words = args.list output_file = args.output_file try: with Client(cli_q_name=cli_q_name, srv_q_name=srv_q_name, srv_b_name=srv_b_name) as cli: cli.run(is_file=is_file, words=words, input_file=input_file, output_file=output_file) except BaseException as e: print("The following error occured:\n{}".format(e))
def send_file(filename, server_ip): packager = File_Packager(filename) client = Client(server_ip) meta_packet, chunks = packager.file_to_chunks() client.send_all_file_chunks(meta_packet, chunks) client.close_socket()
if len(sys.argv) == 4: player_type = sys.argv[1] player_id = sys.argv[2] rand_idx = int(sys.argv[3]) server_id = CLIENTSIDE_SERVER_LIST[rand_idx] # find out our server info server = get_server_info(server_id, servers_list) print "Starting client for %s with id %s, connecting to server %d" % ( player_type, player_id, server_id) # start our client c = Client(publisher_url=server["server2client"], command_url=server["client2server"], player_type=player_type, player_id=player_id, zmq_context=zmq_root_context, verbose=VERBOSE) # wait a bit and let the gamestate comes in # c.wait_for_initial_gamestate() while c.is_game_running() and c.is_char_alive(): if c.is_server_timeout(): # existing server does not send updates print "player %s: server %d does not send any update, finding another server.." % ( player_id, server_id) # find a new server new_rand_idx = rand_idx while new_rand_idx == rand_idx: new_rand_idx = randint(0, len(CLIENTSIDE_SERVER_LIST) - 1)
def register_new_socket(self, socket): self.sockets_to_clients[socket] = Client(socket, self.game_handler)
from client.Client import Client import string import random def _generate_word(length): # https://gist.github.com/noxan/5845351 VOWELS = "aeiou" CONSONANTS = "".join(set(string.ascii_lowercase) - set(VOWELS)) word = "" for i in range(length): if i % 2 == 0: word += random.choice(CONSONANTS) else: word += random.choice(VOWELS) return word c = Client(serverName="localhost", serverPort=12345, username=_generate_word(12)) c.clientSocket.close()
from client.Client import Client import time client = Client('/socket.io', "localhost", 9999) client.connect() time.sleep(5) if client.send("{ \"value\": 123}"): print "Message sent" if client.send("\"echome\""): print "Echo message sent" client.disconnect()