def __init__(self, host, port): super().__init__(host, port) self.slave_id = socket.gethostname() self.client = rpc.Client(self.host, self.port) self.greenlet = Group() self.greenlet.spawn(self.work) self.client.send(rpc.Message('slave_ready', None, self.slave_id))
# Set initial score me_score = 0 enemy_score = 0 # Set initial velocities player_vel = 10 ball_vel = 0 # ball_dir is u, d, r, l ball_dir = 'u' ####################################################################### #### CONNECT TO SERVER #### ####################################################################### conn = Server.Client(MY_SERVER_HOST, MY_SERVER_PORT) data = look_for_match() #match was not found if (data[0] == 'A'): print(data) else: ip_and_port = data.split() OTHER_HOST = ip_and_port[3] OTHER_PORT = int(ip_and_port[4]) MY_PORT = int(ip_and_port[5]) #close connection with server and bind self to MY IP and MY PORT to talk to opponent conn.close() print("Binding to ip: " + MY_IP + " on port: " + str(MY_PORT)) server = Server.Server(MY_IP, MY_PORT)