|
|
@ -28,8 +28,9 @@ public class ChatServer { |
|
|
|
Socket s = server.accept(); |
|
|
|
DataInputStream inputStream = new DataInputStream(s.getInputStream()); |
|
|
|
DataOutputStream outputStream = new DataOutputStream(s.getOutputStream()); |
|
|
|
ChatClient client = new ChatClient(id_q.deq(), s, inputStream, outputStream); |
|
|
|
ChatClient client = new ChatClient(id_q.deq(), s, inputStream, outputStream, this); |
|
|
|
n_users++; |
|
|
|
Main.console.success("Client (" + s.getRemoteSocketAddress().toString() + ") [id: " + client.id + "] connected!"); |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
Main.console.error("An error occurred while listening for connections!"); |
|
|
@ -58,4 +59,11 @@ public class ChatServer { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void disconnect(ChatClient c) { |
|
|
|
c.disconnect(); |
|
|
|
id_q.enq(c.id); |
|
|
|
n_users--; |
|
|
|
Main.console.info("Disconnected client [id: " + c.id + "]"); |
|
|
|
} |
|
|
|
} |