|
@@ -38,21 +38,19 @@ class OutdoorListenerThread extends Thread {
|
38
|
38
|
{
|
39
|
39
|
boolean exit = false;
|
40
|
40
|
boolean accepted = true;
|
41
|
|
- byte[] buffer = new byte[100];
|
42
|
41
|
|
43
|
42
|
|
44
|
43
|
String username;
|
45
|
44
|
String response = "";
|
46
|
45
|
|
47
|
|
- byte[] responseBytes;
|
48
|
46
|
try
|
49
|
47
|
{
|
50
|
48
|
while(!exit)
|
51
|
49
|
{
|
52
|
50
|
try
|
53
|
51
|
{
|
|
52
|
+ ServerSocket servSocket = new ServerSocket(1233);
|
54
|
53
|
System.out.println("Waiting for connection request");
|
55
|
|
- ServerSocket servSocket = new ServerSocket(1234);
|
56
|
54
|
Socket link = servSocket.accept();
|
57
|
55
|
BufferedReader in = new BufferedReader(new InputStreamReader(link.getInputStream()));
|
58
|
56
|
PrintWriter out = new PrintWriter(link.getOutputStream(), true);
|
|
@@ -100,6 +98,7 @@ class OutdoorListenerThread extends Thread {
|
100
|
98
|
knownUsersPanel.append(" " + a.getName() + " \n");
|
101
|
99
|
}
|
102
|
100
|
}
|
|
101
|
+ servSocket.close();
|
103
|
102
|
}
|
104
|
103
|
catch(SocketTimeoutException e) {}
|
105
|
104
|
}
|
|
@@ -424,7 +423,6 @@ public class NetworkClient {
|
424
|
423
|
connectionSocket.close();
|
425
|
424
|
userListSocket.close();
|
426
|
425
|
}
|
427
|
|
-
|
428
|
426
|
else
|
429
|
427
|
{
|
430
|
428
|
Socket requestSocket = new Socket(destinationIP, 1234);
|
|
@@ -435,7 +433,6 @@ public class NetworkClient {
|
435
|
433
|
usernameList = response[0].split(" ");
|
436
|
434
|
addressList = new String[0];
|
437
|
435
|
portNumber = Integer.parseInt(response[2]);
|
438
|
|
- requestSocket.close();
|
439
|
436
|
}
|
440
|
437
|
|
441
|
438
|
for(String u:usernameList)
|
|
@@ -505,6 +502,7 @@ public class NetworkClient {
|
505
|
502
|
{
|
506
|
503
|
Socket s = new Socket(destinationIP, portNumber);
|
507
|
504
|
dest_sockets.add(s);
|
|
505
|
+ (new ReceiveThread(user, s, chatText, known_users, knownUsersPanel, dest_sockets, outdoor_dest_sockets, false)).start();
|
508
|
506
|
}
|
509
|
507
|
catch(IOException e)
|
510
|
508
|
{
|
|
@@ -532,8 +530,6 @@ public class NetworkClient {
|
532
|
530
|
|
533
|
531
|
void send (String message)
|
534
|
532
|
{
|
535
|
|
- System.out.println("Sending message");
|
536
|
|
- System.out.println("Indoor users:");
|
537
|
533
|
for(Socket s:dest_sockets)
|
538
|
534
|
{
|
539
|
535
|
try
|
|
@@ -544,17 +540,6 @@ public class NetworkClient {
|
544
|
540
|
}
|
545
|
541
|
catch(IOException e){}
|
546
|
542
|
}
|
547
|
|
- System.out.println("Outdoor users:");
|
548
|
|
- for(Socket s:outdoor_dest_sockets)
|
549
|
|
- {
|
550
|
|
- try
|
551
|
|
- {
|
552
|
|
- System.out.println(s.getInetAddress().getHostAddress() + ": local port " + s.getLocalPort() + ", remote port " + s.getPort());
|
553
|
|
- ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
|
554
|
|
- out.writeObject(new Message(user.getName(), message));
|
555
|
|
- }
|
556
|
|
- catch(IOException e){}
|
557
|
|
- }
|
558
|
543
|
}
|
559
|
544
|
|
560
|
545
|
void disconnect()
|