| 326 | } |
| 327 | |
| 328 | private void waitConnection() throws IOException |
| 329 | { |
| 330 | |
| 331 | Socket tempSocket = null; |
| 332 | boolean connected = false; |
| 333 | |
| 334 | try |
| 335 | { |
| 336 | tempSocket = serverSocket.accept(); |
| 337 | connected = true; |
| 338 | System.out.println("Connection accepted!"); |
| 339 | } |
| 340 | catch(Exception e) |
| 341 | { |
| 342 | connected = false; |
| 343 | |
| 344 | e.printStackTrace(); |
| 345 | } |
| 346 | |
| 347 | if(connected) |
| 348 | { |
| 349 | Connection connection = new Connection(tempSocket); |
| 350 | |
| 351 | LobbyPlayer player = new LobbyPlayer(connection, this); |
| 352 | new Thread(player).start(); |
| 353 | |
| 354 | synchronized(players) |
| 355 | { |
| 356 | this.players.add(player); |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | public void restartServer() |
| 362 | { |