use of io.netty.handler.codec.http.websocketx.PingWebSocketFrame in project reactor-netty by reactor.
the class WebsocketServerOperations method onInboundNext.
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void onInboundNext(ChannelHandlerContext ctx, Object frame) {
if (frame instanceof CloseWebSocketFrame && ((CloseWebSocketFrame) frame).isFinalFragment()) {
if (log.isDebugEnabled()) {
log.debug(format(channel(), "CloseWebSocketFrame detected. Closing Websocket"));
}
CloseWebSocketFrame closeFrame = new CloseWebSocketFrame(true, ((CloseWebSocketFrame) frame).rsv(), ((CloseWebSocketFrame) frame).content());
if (closeFrame.statusCode() != -1) {
// terminate() will invoke onInboundComplete()
sendCloseNow(closeFrame, f -> terminate());
} else {
// terminate() will invoke onInboundComplete()
sendCloseNow(closeFrame, WebSocketCloseStatus.EMPTY, f -> terminate());
}
return;
}
if (!this.proxyPing && frame instanceof PingWebSocketFrame) {
// "FutureReturnValueIgnored" this is deliberate
ctx.writeAndFlush(new PongWebSocketFrame(((PingWebSocketFrame) frame).content()));
ctx.read();
return;
}
if (frame != LastHttpContent.EMPTY_LAST_CONTENT) {
super.onInboundNext(ctx, frame);
}
}
Aggregations