Tried implementing logout handling (changes only on Server side)
This commit is contained in:
parent
10bbcdf69e
commit
d1b2474702
@ -102,7 +102,8 @@ public class Client {
|
||||
|
||||
public void closeEverything(Socket socket, BufferedReader in, BufferedWriter out) {
|
||||
//TODO Correctly closing a clients connection
|
||||
//TODO the server should be notified in a way so he can handle it cleanly
|
||||
|
||||
// Is this not already correct?
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
|
||||
@ -27,6 +27,12 @@ public class Server {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user