Skip to content

Commit

Permalink
Fix duplicate shutdown messages for clients
Browse files Browse the repository at this point in the history
  • Loading branch information
qixils committed Nov 28, 2021
1 parent 332ceda commit afbf44a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Objects;

class DummyResponse implements JsonObject {
final class DummyResponse implements JsonObject {
int id = 0;
ResultType status;
String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,8 @@ private void loop() {
}
}

private void writeResponse(@NotNull DummyResponse response) {
for (SocketThread socketThread : socketThreads) {
if (socketThread.isSocketActive()) {
response.write(socketThread.socket);
}
}
}

@Override
public void shutdown(@Nullable Request cause, @Nullable String reason) throws IOException {
writeResponse(DummyResponse.from(cause, reason));
rawShutdown(cause, reason);
}

private void rawShutdown(@Nullable Request cause, @Nullable String reason) throws IOException {
running = false;
for (SocketThread socketThread : socketThreads) {
if (socketThread.isSocketActive())
Expand Down

0 comments on commit afbf44a

Please sign in to comment.