Gosh, same bugfix as for python many years ago

This commit is contained in:
Tony Garnock-Jones 2017-01-23 13:32:28 -05:00
parent 66c77df742
commit a8d69e9778
1 changed files with 5 additions and 1 deletions

View File

@ -29,8 +29,12 @@ public class chat {
}
public synchronized void connect(String user, Consumer<String> callback) {
announce(user + " arrived");
for (Map.Entry<String, Consumer<String>> e : members.entrySet()) {
try { callback.accept(e.getKey() + " arrived"); }
catch (Exception ex) { disconnect(e.getKey()); }
}
members.put(user, callback);
announce(user + " arrived");
}
public synchronized void disconnect(String user) {