Fix issue #1
This commit is contained in:
parent
3906c463fd
commit
521f38468b
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user