@Override public void update() { if (readyToConnect && !connectStarted) { Client.reset(new LanClient()); Input.setup(Client.get()); connectStarted = true; } if (Input.isActive(Commands.get(Aigilas.Commands.Start), 0)) { if (ipIn.getText() != null && !ipIn.getText().isEmpty()) { String[] contents = ipIn.getText().split(":"); String address = contents[0]; if (contents.length > 1) { int port = Parse.inte(contents[1]); Config.get().setPort(port); } label.setText(waitMessage); Config.get().setServerIp(address); readyToConnect = true; ipIn.setVisible(false); } } if (Client.get().isGameStarting()) { for (int ii = 0; ii < Client.get().getPlayerCount(); ii++) { Input.setContext(Contexts.get(Sps.Contexts.Free), ii); } StateManager.loadState(new LoadingState()); } }
public ClientManager() { try { this.server = new ServerSocket(Config.get().port()); clientListener = new Thread( new Runnable() { public void run() { while (!Thread.interrupted()) { try { Socket client = server.accept(); clients.add(new MessageHandler(client)); clients.get(clients.size() - 1).owner = "SERVER"; addressToIndex.put(client.getPort(), clients.size() - 1); } catch (IOException e) { Logger.exception(e); } } } }, "ClientManager"); clientListener.start(); } catch (IOException e1) { __otherServerExists = true; Logger.info( "SERVER: Failure to start. If this isn't the host machine, then this message is harmless."); } }