Ejemplo n.º 1
0
 public MainPlayer(int port) {
   try {
     connection = new ChatConnection(false, this);
     connection.start();
   } catch (IOException e) {
     System.out.println("Connecting to server failed");
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 public void run() {
   connection.start();
   System.out.println("\n\nChat started");
   System.out.print("you: ");
   Scanner scanner = new Scanner(System.in);
   while (true) {
     if (scanner.hasNextLine()) {
       System.out.println("yo");
       String line = scanner.nextLine();
       connection.sendMessage(line);
       System.out.println();
       if (line.contains("endsession")) {
         break;
       }
     }
   }
   System.out.println("Session ended.");
   connection.endSession();
   scanner.close();
 }