Beispiel #1
0
def main():
    # print command line arguments
    args = sys.argv

    if len(args) != 6: print 'Insufficient Arguments'

    global lsListenPort
    global ts1Hostname
    global ts1ListenPort
    global ts2Hostname
    global ts2ListenPort

    lsListenPort = int(args[1])
    ts1Hostname = args[2]
    ts1ListenPort = int(args[3])
    ts2Hostname = args[4]
    ts2ListenPort = int(args[5])

    server = Server(lsListenPort)
    ts1client = Client()
    ts2client = Client()

    server.accept()
    contactTSservers(server, ts1client, ts2client)
    server.close()
Beispiel #2
0
def main():
    args = sys.argv
    if len(args) != 4: print 'Insufficient Arguments'

    global rsHostname
    global rsListenPort
    global tsListenPort

    rsHostname = args[1]
    rsListenPort = int(args[2])
    tsListenPort = int(args[3])

    rsclient = Client()
    tsclient = Client()
    queryHostNames(rsclient, tsclient)
Beispiel #3
0
    def __init__(self, stupid=False):
        self.uuid = None
        self.ui = None

        self.net_cli = Client()

        if not stupid:
            self.ui = ui.SnakeUI()
Beispiel #4
0
def main():
    args = sys.argv
    if len(args) != 3: print 'Insufficient Arguments'

    global lsHostname
    global lsListenPort

    lsHostname = args[1]
    lsListenPort = int(args[2])

    lsclient = Client()

    queryHostNames(lsclient)
Beispiel #5
0
def handle_message(data):
    cli = Client()

    client_uuid, command = data.split("|")
    cli.set_uuid(client_uuid)
    cli.send(NEW_CLIENT)

    if command == "up":
        cli.send(GO_UP)
    elif command == "down":
        cli.send(GO_DOWN)
    elif command == "left":
        cli.send(GO_LEFT)
    elif command == "right":
        cli.send(GO_RIGHT)
    elif command == "r":
        cli.send(NEW_CLIENT)
Beispiel #6
0
def run():
    print(f'Enter the host name of the server [Default = {DEFAULT_SERVER_HOSTNAME}]:')
    hostname = input() or DEFAULT_SERVER_HOSTNAME

    print(f'Enter the number of messages per second [Default = {str(DEFAULT_MESSAGES_PER_SECOND)}]:')
    mps = int(input() or DEFAULT_MESSAGES_PER_SECOND)

    joystick = get_joystick()
    # cv_adjust = CVAdjust()

    # parameters = {
    #     'hostname': hostname,
    #     'data_to_send_func': joystick.get_serialized_info,
    #     'receiver_func': handle_input
    # }

    # x = SenderReceiver(**parameters)
    # x.run()

    while True:
        try:
            while True:
                try:
                    client = Client(hostname=hostname, port=SERVER_PORT)
                    break
                except Exception:
                    print('Error happened while connecting to the server. Retrying in 1 second...')
                    sleep(1)

            controller = JoystickController(client=client, joystick=joystick)

            clock = pygame.time.Clock()
            while True:
                clock.tick(mps)
                controller.get_and_send()

        except Exception:
            # TODO end the client.
            print('Error happened while sending the info. Possibly the server has disconnected.')
            print('Trying to connect again...')
            sleep(1)
Beispiel #7
0
    def __init__(self):
        pygame.init()

        d = pygame.display.Info()
        self.desktop_size = (d.current_w, d.current_h)
        self.size = (600, 450)  # self.ui.screen_size()

        pygame.display.set_caption("Mapper")

        self.done = False
        self.clock = pygame.time.Clock()
        self.keys = set()

        self.map = MapDS()
        self.map.expand_room()
        self.screen = pygame.display.set_mode(self.size)
        self.screen.fill((0xFF, ) * 3)
        self.last = None

        self.clicked = 0
        self.client = Client(self)
        self.ui = DungeonUI(self, None)
Beispiel #8
0
def handle_message(user_uuid):
    cli = Client()
    cli.set_uuid(user_uuid)
    resp = cli.send(GET_WORLD)
    emit("map", resp)
Beispiel #9
0
from networking.Client import *
import numpy as np

if __name__ == "__main__":
    robot = Client()
    for i in range(5):
        # compute grasp coords and bounding boxes
        grasp_coords = [[[-.1], [-.2], [.5]], [[0], [-.2], [.5]]]

        # send object containing grasp coords to the computer
        data_packet = grasp_coords
        robot.send_data(data_packet)
        response = robot.listen()
        print(response)
Beispiel #10
0
from networking import Client

client = Client()
client.connect('localhost', 9234)
client.send_data("Hello!")
client.send_input()