Skip to content

Commit

Permalink
Remove finished streams
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Jul 11, 2022
1 parent 7ad1dfb commit b7ddeac
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public void onMessage(String message) {
// End the stream first.
stream.transportReportStatus(Status.fromCode(Status.Code.UNKNOWN));
}
streams.clear();
try {
websocketSession
.close(new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, "Can't read string payloads"));
Expand Down Expand Up @@ -120,6 +121,7 @@ public void onMessage(ByteBuffer message) throws IOException {
// message is empty (no control flow, no data), error
if (stream != null) {
stream.transportReportStatus(Status.fromCode(Status.Code.UNKNOWN));
streams.remove(streamId);
}
websocketSession.close(new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, "Unexpected empty message"));
return;
Expand All @@ -139,11 +141,13 @@ public void onMessage(ByteBuffer message) throws IOException {
// if first byte is 1, the client is finished sending
if (message.remaining() != 0) {
stream.transportReportStatus(Status.fromCode(Status.Code.UNKNOWN));
streams.remove(streamId);
websocketSession.close(
new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, "Unexpected bytes in close message"));
return;
}
stream.inboundDataReceived(ReadableBuffers.empty(), true);
streams.remove(streamId);
return;
}
assert !closed;
Expand All @@ -161,6 +165,7 @@ public void onError(Throwable error) {
for (MultiplexedWebsocketStreamImpl stream : streams.values()) {
stream.transportReportStatus(Status.UNKNOWN);// transport failure of some kind
}
streams.clear();
// onClose will be called automatically
if (error instanceof ClosedChannelException) {
// ignore this for now
Expand Down

0 comments on commit b7ddeac

Please sign in to comment.