Skip to content

Commit

Permalink
[grid] Retaining to increase the reference count once and then close …
Browse files Browse the repository at this point in the history
…the ws properly.

This helps to close the VNC stream properly. Does not affect any of the CDP
ws commands (since they do not go through this path).
  • Loading branch information
diemol committed Jun 16, 2021
1 parent 5385a15 commit 4733eea
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -157,9 +157,10 @@ private void handleHttpRequest(ChannelHandlerContext ctx, HttpRequest req) {

private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) {
if (frame instanceof CloseWebSocketFrame) {
handshaker.close(ctx.channel(), (CloseWebSocketFrame) frame);
CloseWebSocketFrame close = (CloseWebSocketFrame) frame.retain();
handshaker.close(ctx.channel(), close);
// Pass on to the rest of the channel
ctx.fireChannelRead(frame);
ctx.fireChannelRead(close);
} else if (frame instanceof PingWebSocketFrame) {
ctx.write(new PongWebSocketFrame(frame.isFinalFragment(), frame.rsv(), frame.content()));
} else if (frame instanceof ContinuationWebSocketFrame) {
Expand All @@ -170,8 +171,8 @@ private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame fram
// Allow the rest of the pipeline to deal with this.
ctx.fireChannelRead(frame);
} else {
throw new UnsupportedOperationException(String.format("%s frame types not supported", frame.getClass()
.getName()));
throw new UnsupportedOperationException(
String.format("%s frame types not supported", frame.getClass().getName()));
}
}

Expand Down

0 comments on commit 4733eea

Please sign in to comment.