Guest User

Untitled

a guest
Nov 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public class ServerManager extends Application{
  2.  
  3. public static final int PORT = 2000;
  4.  
  5. public static void main(String[] args) throws IOException {
  6. ServerSocket s = new ServerSocket(PORT);
  7. System.out.println("Server socket: " + s);
  8. System.out.println("Server listening...");
  9. try {
  10. while (true) {
  11. // Wait For Connection
  12. Socket socket = s.accept();
  13. System.out.println("Connection accepted.");
  14. System.out.println("The new socket: " + socket);
  15. try {
  16.  
  17. GraphicsManager gm = new GraphicsManager();
  18. gm.createBalls(1, 10, 20, 10, 20, 0, 0);
  19. //gm.start(THESTAGE_BUT_IS_NOT_ACCESSIBLE);
  20. //How would i access the stage-object here? ^
  21. ClientThread t = new ClientThread(socket);
  22. System.out.println("New thread started.");
  23. System.out.println("The new thread: " + t);
  24. } catch (IOException e) {
  25. socket.close();
  26. }
  27. }
  28. } // catch, while, try
  29. finally {
  30. s.close();
  31. }
  32. }
  33.  
  34. //The code below is never run for some reason?
  35.  
  36. @Override
  37. public void start(Stage primaryStage) throws Exception {
  38.  
  39. GraphicsManager gm = new GraphicsManager();
  40. gm.start(primaryStage);
  41.  
  42. }
  43.  
  44. }
Add Comment
Please, Sign In to add comment