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 accepted = true;
|
||||
byte[] buffer = new byte[100];
|
||||
|
||||
|
||||
String username;
|
||||
String response = "";
|
||||
|
||||
byte[] responseBytes;
|
||||
try
|
||||
{
|
||||
while(!exit)
|
||||
{
|
||||
try
|
||||
{
|
||||
ServerSocket servSocket = new ServerSocket(1233);
|
||||
System.out.println("Waiting for connection request");
|
||||
ServerSocket servSocket = new ServerSocket(1234);
|
||||
Socket link = servSocket.accept();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(link.getInputStream()));
|
||||
PrintWriter out = new PrintWriter(link.getOutputStream(), true);
|
||||
|
@ -100,6 +98,7 @@ class OutdoorListenerThread extends Thread {
|
|||
knownUsersPanel.append(" " + a.getName() + " \n");
|
||||
}
|
||||
}
|
||||
servSocket.close();
|
||||
}
|
||||
catch(SocketTimeoutException e) {}
|
||||
}
|
||||
|
@ -424,7 +423,6 @@ public class NetworkClient {
|
|||
connectionSocket.close();
|
||||
userListSocket.close();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Socket requestSocket = new Socket(destinationIP, 1234);
|
||||
|
@ -435,7 +433,6 @@ public class NetworkClient {
|
|||
usernameList = response[0].split(" ");
|
||||
addressList = new String[0];
|
||||
portNumber = Integer.parseInt(response[2]);
|
||||
requestSocket.close();
|
||||
}
|
||||
|
||||
for(String u:usernameList)
|
||||
|
@ -505,6 +502,7 @@ public class NetworkClient {
|
|||
{
|
||||
Socket s = new Socket(destinationIP, portNumber);
|
||||
dest_sockets.add(s);
|
||||
(new ReceiveThread(user, s, chatText, known_users, knownUsersPanel, dest_sockets, outdoor_dest_sockets, false)).start();
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
|
@ -532,8 +530,6 @@ public class NetworkClient {
|
|||
|
||||
void send (String message)
|
||||
{
|
||||
System.out.println("Sending message");
|
||||
System.out.println("Indoor users:");
|
||||
for(Socket s:dest_sockets)
|
||||
{
|
||||
try
|
||||
|
@ -544,17 +540,6 @@ public class NetworkClient {
|
|||
}
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue