Fix issue #1
This commit is contained in:
@@ -5,6 +5,7 @@ import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class MessageDistributer extends OutputStream {
|
||||
private static Map<String, OutputStream> userStreams = new HashMap<>();
|
||||
@@ -30,6 +31,11 @@ public class MessageDistributer extends OutputStream {
|
||||
}
|
||||
|
||||
public void registerStream(String username, OutputStream os) {
|
||||
Set<String> usernames = userStreams.keySet();
|
||||
while (usernames.contains(username)) {
|
||||
username += ".imposter";
|
||||
}
|
||||
|
||||
userStreams.put(username, os);
|
||||
try {
|
||||
this.write(("SERVER> Welcome, " + username + "!\n").getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
Reference in New Issue
Block a user