Added Alexandrs "Tried implementing logout handling (changes only on Server side) " commit
This commit is contained in:
parent
0e39f06f9e
commit
4a5bc49aa7
@ -22,7 +22,6 @@ public class Client {
|
||||
this.out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
|
||||
this.in = new BufferedReader((new InputStreamReader((socket.getInputStream()))));
|
||||
|
||||
String randomUserName = NameGenerator.randomName();
|
||||
//TODO hide connecting logik(next 4 lines)
|
||||
this.userName = userName;
|
||||
this.out.write(getUsername());
|
||||
|
||||
@ -26,6 +26,12 @@ public class Server {
|
||||
Thread th = new Thread(nextClient);
|
||||
connectedClients.add(nextClient);
|
||||
th.start();
|
||||
// close socket + remove client if client is disconnected
|
||||
if (socket.getInputStream().read() == -1) {
|
||||
System.out.println("client disconnected. closing socket");
|
||||
socket.close();
|
||||
connectedClients.remove(nextClient);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user