Beispiel #1
0
 public static void main(String[] args) {
   if (args.length != 1) {
     System.out.println("\nbad args");
     System.out.println(
         "usage:java hw3.java TEMPLETON_STARTING_VALUE SIKORSKI_STARTING_VALUE CR89_STARTING_VALUE\n");
   } else {
     try {
       Client client1 =
           new Client(
               "TEMPLETON",
               MONITOR_NAME,
               MONITOR_PORT,
               HOST_NAME,
               44444,
               Integer.parseInt(args[0]),
               Integer.parseInt(args[1]),
               Integer.parseInt(args[2]));
       client1.start();
       Server server1 = new Server("TEMPLETON", MONITOR_PORT, 44444);
       server1.start();
       Client client2 =
           new Client(
               "SIKORSKI",
               MONITOR_NAME,
               MONITOR_PORT,
               HOST_NAME,
               44445,
               Integer.parseInt(args[0]),
               Integer.parseInt(args[1]),
               Integer.parseInt(args[2]));
       client2.start();
       Server server2 = new Server("SIKORSKI", MONITOR_PORT, 44445);
       server2.start();
       Client client3 =
           new Client(
               "CR89",
               MONITOR_NAME,
               MONITOR_PORT,
               HOST_NAME,
               44446,
               Integer.parseInt(args[0]),
               Integer.parseInt(args[1]),
               Integer.parseInt(args[2]));
       client3.start();
       Server server3 = new Server("CR89", MONITOR_PORT, 44446);
       server3.start();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
 public void btn1_onClick(View view) {
   Log.w("HablamosClient", "Boton 1 pulsado");
   tClient.setUserNum(
       Integer.parseInt(((EditText) findViewById(R.id.txtUsuario)).getText().toString()));
   tClient.start();
   view.setBackgroundColor(Color.BLACK);
 }
Beispiel #3
0
  @BeforeClass
  public static void initializeTest() throws Exception {
    FSUtils.delTree(new java.io.File(SetupUtils.TEST_DIR));

    Logging.start(SetupUtils.DEBUG_LEVEL, SetupUtils.DEBUG_CATEGORIES);

    dirConfig = SetupUtils.createDIRConfig();
    dir = new DIRRequestDispatcher(dirConfig, SetupUtils.createDIRdbsConfig());
    dir.startup();
    dir.waitForStartup();

    testEnv =
        new TestEnvironment(
            new TestEnvironment.Services[] {
              TestEnvironment.Services.DIR_CLIENT,
              TestEnvironment.Services.TIME_SYNC,
              TestEnvironment.Services.RPC_CLIENT,
              TestEnvironment.Services.MRC
            });
    testEnv.start();

    userCredentials = UserCredentials.newBuilder().setUsername("test").addGroups("test").build();

    dirAddress = testEnv.getDIRAddress().getHostName() + ":" + testEnv.getDIRAddress().getPort();
    mrcAddress = testEnv.getMRCAddress().getHostName() + ":" + testEnv.getMRCAddress().getPort();

    defaultCoordinates =
        VivaldiCoordinates.newBuilder()
            .setXCoordinate(0)
            .setYCoordinate(0)
            .setLocalError(0)
            .build();
    defaultStripingPolicy =
        StripingPolicy.newBuilder()
            .setType(StripingPolicyType.STRIPING_POLICY_RAID0)
            .setStripeSize(128)
            .setWidth(1)
            .build();

    osds = new OSD[4];
    configs = SetupUtils.createMultipleOSDConfigs(4);

    // start three OSDs
    osds[0] = new OSD(configs[0]);
    osds[1] = new OSD(configs[1]);
    osds[2] = new OSD(configs[2]);
    osds[3] = new OSD(configs[3]);

    mrcClient = new MRCServiceClient(testEnv.getRpcClient(), null);

    options = new Options();
    client = ClientFactory.createClient(dirAddress, userCredentials, null, options);
    client.start();
  }
Beispiel #4
0
 /**
  * Runs the stress test.
  *
  * @param clients number of clients
  * @throws Exception exception
  */
 private void run(final int clients) throws Exception {
   // run server instance
   server = createServer();
   // run clients
   final Client[] cl = new Client[clients];
   for (int i = 0; i < clients; ++i) cl[i] = new Client();
   for (final Client c : cl) c.start();
   for (final Client c : cl) c.join();
   // stop server
   stopServer(server);
 }
Beispiel #5
0
  public static void main(String[] args) {

    Shop shop = new Shop("Fantastiko");
    shop.setName("Fantastiko");
    shop.start();
    Client client1 = new Client("Bai Gosho", shop);
    client1.setName(client1.name);
    Client client2 = new Client("Bai Ivan", shop);
    client2.setName(client2.name);
    Client client3 = new Client("Bai Nasko", shop);
    client3.setName(client3.name);
    client1.start();
    client2.start();
    client3.start();

    Shop shop2 = new Shop("Lidl");
    shop2.setName("Lidl");
    shop2.start();
    Client client4 = new Client("Komshito", shop2);
    client4.setName(client4.name);
    Client client5 = new Client("Jenata na komshito", shop2);
    client5.setName(client5.name);
    Client client6 = new Client("Sina na komshito", shop2);
    client6.setName(client6.name);
    client4.start();
    client5.start();
    client6.start();

    Shop shop3 = new Shop("Baba Qga");
    shop3.setName("Baba Qga");
    shop3.start();
    Client client7 = new Client("Edin ot Sofia", shop);
    client7.setName(client7.name);
    Client client8 = new Client("Edin ot Petrich", shop);
    client8.setName(client8.name);
    Client client9 = new Client("Vliubena dvoika", shop);
    client9.setName(client9.name);
    client7.start();
    client8.start();
    client9.start();

    Thread suplier = new Suplier("DOSTAVKI OOD");
    suplier.setName("DOSTAVKI OOD");
    suplier.start();
  }
 public static void main(String[] args) {
   Server1 s1 = new Server1();
   s1.start();
   Server2 s2 = new Server2();
   s2.start();
   try {
     Thread.currentThread().sleep(5000);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   Client c = new Client();
   c.start();
 }
  /**
   * Runs the stress test.
   *
   * @param clients number of clients
   * @param runs number of runs per client
   * @throws Exception exception
   */
  private static void run(final int clients, final int runs) throws Exception {
    // Create test database
    Command cmd = new CreateDB(NAME, INPUT);
    cmd.execute(context);

    // Start clients
    final Client[] cl = new Client[clients];
    for (int i = 0; i < clients; ++i) cl[i] = new Client(runs);
    for (final Client c : cl) c.start();
    for (final Client c : cl) c.join();
    // Drop database
    cmd = new DropDB(NAME);
    cmd.execute(context);
  }
Beispiel #8
0
  /*
   * To start the Client in console mode use one of the following command
   * > java Client
   * > java Client username
   * > java Client username portNumber
   * > java Client username portNumber serverAddress
   * at the console prompt
   * If the portNumber is not specified 1500 is used
   * If the serverAddress is not specified "localHost" is used
   * If the username is not specified "Anonymous" is used
   * > java Client
   * is equivalent to
   * > java Client Anonymous 1500 localhost
   * are equivalent
   *
   * In console mode, if an error occurs the program simply stops
   * when a GUI id used, the GUI is informed of the disconnection
   */
  public static void main(String[] args) {
    int portNumber = 1500;
    String serverAddress = "localhost";
    String userName = "******";

    switch (args.length) {
        // > javac Client username portNumber serverAddr
      case 3:
        serverAddress = args[2];
        // > javac Client username portNumber
      case 2:
        try {
          portNumber = Integer.parseInt(args[1]);
        } catch (Exception e) {
          System.out.println("Invalid port number.");
          System.out.println("Usage is: > java Client [username] [portNumber] [serverAddress]");
          return;
        }
        // > javac Client username
      case 1:
        userName = args[0];
        // > java Client
      case 0:
        break;
        // invalid number of arguments
      default:
        System.out.println("Usage is: > java Client [username] [portNumber] {serverAddress]");
        return;
    }
    Client client = new Client(serverAddress, portNumber, userName);
    if (!client.start()) {
      return;
    }
    Scanner scan = new Scanner(System.in);
    while (true) {
      System.out.print("> ");
      String msg = scan.nextLine();
      if (msg.equalsIgnoreCase("LOGOUT")) {
        client.sendMessage(new ChatMessage(ChatMessage.LOGOUT, ""));
        break;
      } else if (msg.equalsIgnoreCase("WHOISIN")) {
        client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""));
      } else {
        client.sendMessage(new ChatMessage(ChatMessage.MESSAGE, msg));
      }
    }
    client.disconnect();
  }
 /**
  * Runs the stress test.
  *
  * @param clients number of clients
  * @param runs number of runs per client
  * @throws Exception exception
  */
 private void run(final int clients, final int runs) throws Exception {
   // run server instance
   server = createServer();
   // create test database
   try (final ClientSession cs = createClient()) {
     cs.execute("create db test <test/>");
     // run clients
     final Client[] cl = new Client[clients];
     for (int i = 0; i < clients; ++i) cl[i] = new Client(runs, i % 2 == 0);
     for (final Client c : cl) c.start();
     for (final Client c : cl) c.join();
     // drop database and stop server
     cs.execute("drop db test");
   }
   stopServer(server);
 }
Beispiel #10
0
  /**
   * Test the http protocol handler with the given authentication schemes in the WWW-Authenticate
   * header.
   */
  static void test(String... schemes) throws IOException {

    // the authentication scheme that the client is expected to choose
    String expected = null;
    for (String s : schemes) {
      if (expected == null) {
        expected = s;
      } else if (s.equals("Digest")) {
        expected = s;
      }
    }

    // server reply
    String reply = authReplyFor(schemes);

    System.out.println("====================================");
    System.out.println("Expect client to choose: " + expected);
    System.out.println(reply);

    try (ServerSocket ss = new ServerSocket(0)) {
      Client.start(ss.getLocalPort());

      // client ---- GET ---> server
      // client <--- 401 ---- server
      try (Socket s = ss.accept()) {
        new MessageHeader().parseHeader(s.getInputStream());
        s.getOutputStream().write(reply.getBytes("US-ASCII"));
      }

      // client ---- GET ---> server
      // client <--- 200 ---- server
      String auth;
      try (Socket s = ss.accept()) {
        MessageHeader mh = new MessageHeader();
        mh.parseHeader(s.getInputStream());
        s.getOutputStream().write(OKAY.getBytes("US-ASCII"));
        auth = mh.findValue("Authorization");
      }

      // check Authorization header
      if (auth == null) throw new RuntimeException("Authorization header not found");
      System.out.println("Server received Authorization header: " + auth);
      String[] values = auth.split(" ");
      if (!values[0].equals(expected)) throw new RuntimeException("Unexpected value");
    }
  }
Beispiel #11
0
        public void actionPerformed(ActionEvent ev) {

          if (ev.getActionCommand().equals("Verbinden")) {
            try {
              System.out.println("Verbinden gedrückt");
              Main.setIP(1, Integer.parseInt(ip1.getText()));
              Main.setIP(2, Integer.parseInt(ip2.getText()));
              Main.setIP(3, Integer.parseInt(ip3.getText()));
              Main.setIP(4, Integer.parseInt(ip4.getText()));
              Main.is_client = true;
              Main.setNetzwerkStatus(true);
              Client.establishConnection();
              Client.connect();
              Client cli = new Client(true);
              cli.start();
              ipframe.dispose();
            } catch (Exception e) {
              System.out.println("Fehler beim Einlesen der IP");
            }
          }
        }
 public static void serverLoop() {
   try {
     ss = new ServerSocket(RemoteControl.props.getInt("port", 11946));
   } catch (IOException e) {
     log.severe("RemoteControl could not bind to port");
   }
   try {
     while (loop) {
       Client c =
           RemoteControl.isParanoid()
               ? new SecureClient(ss.accept())
               : new NormalClient(ss.accept());
       clients.add(c);
       c.setName(c.getName().replace("Thread", "Client"));
       c.start();
     }
   } catch (IOException e) {
     log.info("RemoteControl could not set up connection to client" + " or was disabled");
   } catch (NullPointerException e) {
     // duhr, ss failed.
   }
 }
Beispiel #13
0
 @Override
 protected void started() {
   try {
     coreDomains.start();
     if (legacy != null) {
       legacy.start();
       LOGGER.info("Server Setup Done");
     }
     if (client != null) {
       client.start();
     }
   } catch (InterruptedException e) {
     Thread.currentThread().interrupt();
   } catch (ExecutionException e) {
     LOGGER.error("Failed to start location manager: {}", e.getCause().toString());
     kill();
   } catch (RuntimeException e) {
     LOGGER.error("Failed to start location manager", e);
     kill();
   } catch (Exception e) {
     LOGGER.error("Failed to start location manager: {}", e.toString());
     kill();
   }
 }
  public void actionPerformed(ActionEvent e) {
    Object o = e.getSource();

    for (JRadioButton u : ub) {
      if (o == u) {
        mapTM.setUnitType(u.getText());
        System.out.println("Set unit type - " + u.getText());
        return;
      }
    }

    if (o == timer) {

      /*
      mmLabel.setText("Main Menu ("+(cdTime--)+")");

      if(cdTime == 0){
      	timer.stop();
      	gsButton.setText("Game Start");
      	mmLabel.setText("Main Menu");

      	ArrayList<Building> bArr = new ArrayList<Building>();

      	String temp = "Elixir Collector-24,8-960|Elixir Collector-31,8-960|Gold Mine-17,10-960|Elixir Collector-25,21-960|Elixir Collector-11,22-960";
      	String[] bs = temp.split("\\|");
      	for(String b : bs){
      		String[] bParts = b.split("-");
      		String[] cParts = bParts[1].split(",");
      		int x = Integer.parseInt(cParts[0].trim());
      		int y = Integer.parseInt(cParts[1].trim());

      		Building tb = new Building(bParts[0], new Coordinate(x,y));
      		tb.setHp(Integer.parseInt(bParts[2].trim()));

      		bArr.add(tb);
      	}



      	mapTM.setBuildings(bArr);
      	switchCards("TM");
      }
      */

      return;
    }

    if (o == gsButton) {

      if (timer.isRunning()) {
        // timer.stop();
        gsButton.setText("Game Start");
        mmLabel.setText("Main Menu");
        // sends the leave command
        client.sendUDP("leave~" + unameUDP);
        return;
      }
      // sends the joinlobby command
      client.sendUDP("joinlobby~" + unameUDP);
      // gsButton.setText("Game Stop");
      String serverResp = client.receiveUDP();

      if (serverResp.trim().equals("false")) {

        // place false handler here

      } else {

        String[] enemies = serverResp.trim().split(",");
        ArrayList<Building> bArr = new ArrayList<Building>();
        String mapConfig = getBaseConfig(enemies[0]);
        String[] bs = mapConfig.split("\\|");
        for (String b : bs) {

          String[] bParts = b.split("-");
          String[] cParts = bParts[1].split(",");
          int x = Integer.parseInt(cParts[0].trim());
          int y = Integer.parseInt(cParts[1].trim());

          Building tb = new Building(bParts[0], new Coordinate(x, y));
          tb.setHp(Integer.parseInt(bParts[2].trim()));
          bArr.add(tb);
        }

        mapTM.setBuildings(bArr);
        switchCards("TM");
      }

      // System.out.println(serverResp);
      // cdTime = 10;
      // timer.start();
      return;
    }

    if (o == logout) {
      client.sendMessage(new ChatMessage(ChatMessage.LOGOUT, ""));
      chatArea.setText("");

      switchCards("Login");
      return;
    }

    if (o == cmButton) {
      String baseConfig = getBaseConfig();
      System.out.println("base config: " + baseConfig);

      for (int i = 0; i < mapSize; i++) {
        for (int j = 0; j < mapSize; j++) {
          tiles[i][j].setValue("");
        }
      }

      if (!baseConfig.equals("")) {

        String[] bs = baseConfig.split("\\|");
        for (String b : bs) {
          String[] bParts = b.split("-");
          String[] cParts = bParts[1].split(",");
          int x = Integer.parseInt(cParts[0].trim());
          int y = Integer.parseInt(cParts[1].trim());

          int index = 0;
          for (int i = 0; i < bb.size(); i++) {
            if (bb.get(i).getText().split("-")[0].trim().equals(bParts[0])) {
              index = i;
              break;
            }
          }
          insertBuilding(y, x, index);
        }
      }

      switchCards("CM");

      return;
    }

    if (o == tmButton) {

      ArrayList<Building> bArr = new ArrayList<Building>();

      for (int i = 0; i < 40; i++) {
        for (int j = 0; j < 40; j++) {
          if (tiles[i][j].getValue().equals("") || tiles[i][j].getValue().contains("-")) {
            continue;
          }
          // weird part here
          bArr.add(new Building(tiles[i][j].getValue(), new Coordinate(j, i)));
        }
      }

      mapTM.setBuildings(bArr);

      switchCards("TM");
      return;
    }

    // if it the who is in button
    if (o == whoIsIn) {
      client.sendMessage(new ChatMessage(ChatMessage.WHOISIN, ""));
      return;
    }

    if (o == cmBack) {
      ArrayList<Building> bArr = new ArrayList<Building>();
      for (int i = 0; i < 40; i++) {
        for (int j = 0; j < 40; j++) {
          if (tiles[i][j].getValue().equals("") || tiles[i][j].getValue().contains("-")) {
            continue;
          }
          // weird part here
          bArr.add(new Building(tiles[i][j].getValue(), new Coordinate(j, i)));
        }
      }

      String temp = "mapdata~" + unameUDP + "~";
      int tileCount = 40;
      int dim = 600;
      int tileDim = (int) (dim / tileCount);
      int counter = 0;
      for (Building b : bArr) {
        int x, y, hp;
        x = b.getPos().getX() / tileDim;
        y = b.getPos().getY() / tileDim;
        hp = b.getHp();
        temp += b.getName() + "-" + x + "," + y + "-" + hp + "|";
        counter += 1;
      }
      if (counter > 0) {
        temp = temp.substring(0, temp.length() - 1); // removes the last '|'
      } else {
        temp += "none";
      }

      client.sendUDP(temp); // allows saving of the current state of the map into the user's account

      switchCards("Menu");

      return;
    }
    if (o == tmBack) {
      switchCards("Menu");

      return;
    }

    for (int i = 0; i < 40; i++) {
      for (int j = 0; j < 40; j++) {
        if (o == tiles[i][j]) {
          for (int k = 0; k < bb.size(); k++) {
            if (bb.get(k).isSelected()) {
              if (bb.get(k).getText().equals("Remove Building")) {
                removeBuilding(i, j);
                return;
              }

              insertBuilding(i, j, k);
              // JOptionPane.showMessageDialog(null, bb.get(k).getText());
              return;
            }
          }

          // JOptionPane.showMessageDialog(null, "i-"+i+" j-"+j);
          return;
        }
      }
    }

    // ok it is coming from the JTextField
    if (connected) {
      // just have to send the message
      client.sendMessage(new ChatMessage(ChatMessage.MESSAGE, chatField.getText()));
      chatField.setText("");
      return;
    }

    if (o == login) {
      // ok it is a connection request
      String username = usernameField.getText().trim();
      String password = passwordField.getText().trim();
      // empty username ignore it
      if (username.length() == 0) return;
      // empty serverAddress ignore it
      String server = tfServer.getText().trim();
      if (server.length() == 0) return;
      // empty or invalid port numer, ignore it
      String portNumber = tfPort.getText().trim();
      if (portNumber.length() == 0) return;
      int port = 0;
      try {
        port = Integer.parseInt(portNumber);
      } catch (Exception en) {
        return; // nothing I can do if port number is not valid
      }

      // try creating a new Client with GUI
      client = new Client(server, port, username, password, this);
      // test if we can start the Client
      if (!client.start()) return;

      unameUDP = username;

      switchCards("Menu");
      // fetching of the base_config string from the database

      chatField.setText("");
      chatArea.setText("");
    }
  }
Beispiel #15
0
 public static void main(String[] argv) throws Exception {
   Client client = new Client();
   client.start();
   client.end();
 }
Beispiel #16
0
  public JavaGame(String[] args) {
    this.args = args;
    updater = new Updater(this);
    highscore = new Highscore(this);
    eventHandler = new EventHandler(this);
    eventHandler.registerTestEvents();

    setTitle("Survive-JavaGame"); // Fenstertitel setzen
    setSize(1200, 900); // Fenstergröße einstellen
    addWindowListener(new WindowListener());
    setLocationRelativeTo(null);

    try {
      arg = args[0];
    } catch (ArrayIndexOutOfBoundsException e) {
      arg = "nothing";
    }
    if (arg.equals("fullscreen")) {
      setUndecorated(true); // "Vollbild"
      setSize(
          (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() - 200,
          (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth());
      setLocation(0, 0);
    }
    setVisible(true);
    setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

    try {
      /*URI Path = URLDecoder.decode(getClass().getClassLoader().getResource("texture").toURI();//, "UTF-8"); //Pfad zu den Resourcen
      File F = new File(Path);
      basePath = F;
      System.out.println(basePath);
      */
      File File = new File((System.getenv("APPDATA")));
      basePath = new File(File, "/texture");
      backgroundTexture = new File(basePath, "/hintergrund.jpg");
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    try {
      backgroundImage = ImageIO.read(backgroundTexture);
    } catch (IOException exeption) {

    }

    if (soundan) {
      currentVolume = 80;
    } // end of if

    dbImage = createImage(1920, 1080);
    // dbGraphics = dbImage.getGraphics();

    // Texturen Liste

    // Ebenen Liste

    ebenen[0][0] = 91;
    ebenen[0][1] = 991; // Main Ebene: Kann nicht durchschrittenwerden indem down gedrückt wird
    ebenen[0][2] = 563;

    ebenen[1][0] = 387; // x1
    ebenen[1][1] = 524; // x2
    ebenen[1][2] = 454; // y

    ebenen[2][0] = 525;
    ebenen[2][1] = 645;
    ebenen[2][2] = 350;

    ebenen[3][0] = 246;
    ebenen[3][1] = 365;
    ebenen[3][2] = 351;

    ebenen[4][0] = 760;
    ebenen[4][1] = 870;
    ebenen[4][2] = 294;

    ebenen[5][0] = 835;
    ebenen[5][1] = 969;
    ebenen[5][2] = 441;

    // Spieler

    // I'm in Space! SPACE!
    player[1] =
        new Player(
            (int) (Math.random() * (ebenen[0][1] - ebenen[0][0]) + ebenen[0][0]),
            0,
            false,
            67,
            100,
            texture[0],
            shottexture[0],
            KeyEvent.VK_A,
            KeyEvent.VK_D,
            KeyEvent.VK_W,
            KeyEvent.VK_S,
            KeyEvent.VK_Q,
            1,
            35,
            highscore.getName(1));
    player[2] =
        new Bot(
            (int) (Math.random() * (ebenen[0][1] - ebenen[0][0]) + ebenen[0][0]),
            0,
            false,
            67,
            100,
            texture[1],
            shottexture[1],
            KeyEvent.VK_J,
            KeyEvent.VK_L,
            KeyEvent.VK_I,
            KeyEvent.VK_K,
            KeyEvent.VK_U,
            2,
            35,
            highscore.getName(1));
    player[3] =
        new Bot(
            (int) (Math.random() * (ebenen[0][1] - ebenen[0][0]) + ebenen[0][0]),
            0,
            false,
            67,
            100,
            texture[2],
            shottexture[2],
            KeyEvent.VK_LEFT,
            KeyEvent.VK_RIGHT,
            KeyEvent.VK_UP,
            KeyEvent.VK_DOWN,
            KeyEvent.VK_ENTER,
            3,
            35,
            highscore.getName(1));

    player[1].laden(this);
    player[2].laden(this);
    player[3].laden(this);

    this.addKeyListener(player[1]);
    this.addKeyListener(player[2]);
    this.addKeyListener(player[3]);

    this.addKeyListener(this);

    int result;
    Object[] options = {"SinglePlayer", "MultiPlayer"};
    if (arg.equals("dedicated")) {
      Server server = new Server();
      this.server = true;
      setVisible(false);

    } else {
      if ((result =
              JOptionPane.showOptionDialog(
                  null,
                  "Treffen Sie eine Auswahl",
                  "Alternativen",
                  JOptionPane.DEFAULT_OPTION,
                  JOptionPane.INFORMATION_MESSAGE,
                  null,
                  options,
                  options[0]))
          == 1) {
        client = new Client(this);
        online = true;
        while ((onlinename =
                    JOptionPane.showInputDialog(
                        null,
                        "Geben Sie Ihren Namen ein",
                        "Eine Eingabeaufforderung",
                        JOptionPane.PLAIN_MESSAGE))
                .isEmpty()
            && onlinename != null) {}

        Object[] optionsmp = {"Host", "Client"};
        if ((result =
                JOptionPane.showOptionDialog(
                    null,
                    "Treffen Sie eine Auswahl",
                    "Alternativen",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.INFORMATION_MESSAGE,
                    null,
                    optionsmp,
                    optionsmp[0]))
            == 0) {
          Server server = new Server();
          this.server = true;
        } else if (online) {
          while ((serveradresse =
                      JOptionPane.showInputDialog(
                          null,
                          "Geben Sie die Serveradresse ein",
                          "Eine Eingabeaufforderung",
                          JOptionPane.PLAIN_MESSAGE))
                  .isEmpty()
              && serveradresse != null) {}
        }
      }
    }
    if (!arg.equals("dedicated")) {
      gamerunner = new GameRunner(player, this);
      DamageLogig = new damageLogig(gamerunner);
    }

    if (online) {
      try {
        client.initialise(serveradresse, 9876);
        client.start();
      } catch (SocketException e) {
        e.printStackTrace();
      } catch (UnknownHostException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  } // end of init