Browse Source

outdoor users(9)

Louis Farina 11 months ago
parent
commit
6aba42871c
1 changed files with 17 additions and 6 deletions
  1. 17
    6
      src/chat/NetworkClient.java

+ 17
- 6
src/chat/NetworkClient.java View File

@@ -437,6 +437,7 @@ public class NetworkClient {
437 437
       DatagramPacket responsePacket;
438 438
       
439 439
       String[] usernameList;
440
+      String[] outdoorUsernameList;
440 441
       String[] addressList;
441 442
             
442 443
       int portNumber = 1237;
@@ -472,8 +473,9 @@ public class NetworkClient {
472 473
 	            	String[] response = new String(responsePacket.getData()).trim().split(";");	
473 474
 	            	
474 475
 	            	usernameList = response[0].split(" ");
475
-	            	addressList = response[1].split(" ");
476
-	                portNumber = Integer.parseInt(response[2]);
476
+	            	outdoorUsernameList = response[1].split(" ");
477
+	            	addressList = response[2].split(" ");
478
+	                portNumber = Integer.parseInt(response[3]);
477 479
 	                
478 480
 	                connectionSocket.close();
479 481
 		            userListSocket.close();
@@ -486,8 +488,9 @@ public class NetworkClient {
486 488
 	          		  out.println(username);
487 489
 	          		  String[] response = in.readLine().split(";");
488 490
 	          		  usernameList = response[0].split(" ");
491
+		              outdoorUsernameList = response[1].split(" ");
489 492
 	          		  addressList = new String[0];
490
-	                  portNumber = Integer.parseInt(response[2]);
493
+	                  portNumber = Integer.parseInt(response[3]);
491 494
 	          	}
492 495
             	
493 496
             	for(String u:usernameList)
@@ -566,17 +569,25 @@ public class NetworkClient {
566 569
           }
567 570
           
568 571
           user.setName(username);
569
-          known_users.add(new User(username));
572
+          if(!outdoor)
573
+        	  known_users.add(new User(username));
574
+          else
575
+        	 known_outdoor_users.add(new User(username));
570 576
           Collections.sort(known_users);
571 577
           
572 578
           chatText.append(username + " has joined the chat.\n");
573 579
           chatText.setCaretPosition(chatText.getDocument().getLength());
574 580
           
575 581
           knownUsersPanel.setText("");
576
-          knownUsersPanel.append(" Online :\n");
582
+          knownUsersPanel.append("Indoor users:\n");
577 583
           for(User a:known_users)
578 584
           {
579
-        	  knownUsersPanel.append(" " + a.getName() + "  \n");
585
+          	knownUsersPanel.append(" " + a.getName() + "  \n");
586
+          }
587
+          knownUsersPanel.append("\nOutdoor users:\n");
588
+          for(User a:known_outdoor_users)
589
+          {
590
+          	knownUsersPanel.append(" " + a.getName() + "  \n");
580 591
           }
581 592
       }
582 593
       

Loading…
Cancel
Save