outdoor users(4)
This commit is contained in:
parent
9c77df53a8
commit
77a9c46bcc
1 changed files with 3 additions and 18 deletions
|
@ -38,21 +38,19 @@ class OutdoorListenerThread extends Thread {
|
||||||
{
|
{
|
||||||
boolean exit = false;
|
boolean exit = false;
|
||||||
boolean accepted = true;
|
boolean accepted = true;
|
||||||
byte[] buffer = new byte[100];
|
|
||||||
|
|
||||||
|
|
||||||
String username;
|
String username;
|
||||||
String response = "";
|
String response = "";
|
||||||
|
|
||||||
byte[] responseBytes;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while(!exit)
|
while(!exit)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
ServerSocket servSocket = new ServerSocket(1233);
|
||||||
System.out.println("Waiting for connection request");
|
System.out.println("Waiting for connection request");
|
||||||
ServerSocket servSocket = new ServerSocket(1234);
|
|
||||||
Socket link = servSocket.accept();
|
Socket link = servSocket.accept();
|
||||||
BufferedReader in = new BufferedReader(new InputStreamReader(link.getInputStream()));
|
BufferedReader in = new BufferedReader(new InputStreamReader(link.getInputStream()));
|
||||||
PrintWriter out = new PrintWriter(link.getOutputStream(), true);
|
PrintWriter out = new PrintWriter(link.getOutputStream(), true);
|
||||||
|
@ -100,6 +98,7 @@ class OutdoorListenerThread extends Thread {
|
||||||
knownUsersPanel.append(" " + a.getName() + " \n");
|
knownUsersPanel.append(" " + a.getName() + " \n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
servSocket.close();
|
||||||
}
|
}
|
||||||
catch(SocketTimeoutException e) {}
|
catch(SocketTimeoutException e) {}
|
||||||
}
|
}
|
||||||
|
@ -424,7 +423,6 @@ public class NetworkClient {
|
||||||
connectionSocket.close();
|
connectionSocket.close();
|
||||||
userListSocket.close();
|
userListSocket.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Socket requestSocket = new Socket(destinationIP, 1234);
|
Socket requestSocket = new Socket(destinationIP, 1234);
|
||||||
|
@ -435,7 +433,6 @@ public class NetworkClient {
|
||||||
usernameList = response[0].split(" ");
|
usernameList = response[0].split(" ");
|
||||||
addressList = new String[0];
|
addressList = new String[0];
|
||||||
portNumber = Integer.parseInt(response[2]);
|
portNumber = Integer.parseInt(response[2]);
|
||||||
requestSocket.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String u:usernameList)
|
for(String u:usernameList)
|
||||||
|
@ -505,6 +502,7 @@ public class NetworkClient {
|
||||||
{
|
{
|
||||||
Socket s = new Socket(destinationIP, portNumber);
|
Socket s = new Socket(destinationIP, portNumber);
|
||||||
dest_sockets.add(s);
|
dest_sockets.add(s);
|
||||||
|
(new ReceiveThread(user, s, chatText, known_users, knownUsersPanel, dest_sockets, outdoor_dest_sockets, false)).start();
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
|
@ -532,8 +530,6 @@ public class NetworkClient {
|
||||||
|
|
||||||
void send (String message)
|
void send (String message)
|
||||||
{
|
{
|
||||||
System.out.println("Sending message");
|
|
||||||
System.out.println("Indoor users:");
|
|
||||||
for(Socket s:dest_sockets)
|
for(Socket s:dest_sockets)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -544,17 +540,6 @@ public class NetworkClient {
|
||||||
}
|
}
|
||||||
catch(IOException e){}
|
catch(IOException e){}
|
||||||
}
|
}
|
||||||
System.out.println("Outdoor users:");
|
|
||||||
for(Socket s:outdoor_dest_sockets)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
System.out.println(s.getInetAddress().getHostAddress() + ": local port " + s.getLocalPort() + ", remote port " + s.getPort());
|
|
||||||
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
|
|
||||||
out.writeObject(new Message(user.getName(), message));
|
|
||||||
}
|
|
||||||
catch(IOException e){}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void disconnect()
|
void disconnect()
|
||||||
|
|
Loading…
Reference in a new issue