Package org.openqa.selenium.netty.server
Class WebSocketFrameProxy
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
org.openqa.selenium.netty.server.WebSocketFrameProxy
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class WebSocketFrameProxy
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
Installed in the client-side Netty pipeline by
ProxyWebsocketsIntoGrid after the WebSocket upgrade handshake
completes on both sides. It replaces the MessageInboundConverter → WebSocketMessageHandler chain by forwarding WebSocketFrame objects directly to the
node-side WebSocket, avoiding one intermediate Message allocation and one
executor-task submission per frame.
The reverse direction (node → client) is handled by DirectForwardingListener inside
ProxyWebsocketsIntoGrid, which writes TextWebSocketFrame/BinaryWebSocketFrame directly to the client Channel, bypassing MessageOutboundConverter.
Close frames are intentionally NOT handled here — they continue to flow through WebSocketUpgradeHandler which calls the registered Consumer<Message> with a CloseMessage and runs the Netty-level close handshake.
This handler is not @ChannelHandler.Sharable: each connection gets its own instance so
that the fragmentation accumulators are per-connection.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketFrameProxy(org.openqa.selenium.remote.http.WebSocket upstream, AtomicBoolean upstreamClosing) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.websocketx.WebSocketFrame frame) static voidwriteBinaryFrame(io.netty.channel.Channel clientChannel, byte[] data) Called by the node-sideForwardingListenerto write a binary frame directly to the client channel, bypassingMessageOutboundConverter.static voidwriteTextFrame(io.netty.channel.Channel clientChannel, CharSequence text) Called by the node-sideForwardingListenerto write a text frame directly to the client channel, bypassingMessageOutboundConverter.Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
WebSocketFrameProxy
public WebSocketFrameProxy(org.openqa.selenium.remote.http.WebSocket upstream, AtomicBoolean upstreamClosing)
-
-
Method Details
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.websocketx.WebSocketFrame frame) - Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
-
writeTextFrame
Called by the node-sideForwardingListenerto write a text frame directly to the client channel, bypassingMessageOutboundConverter. -
writeBinaryFrame
public static void writeBinaryFrame(io.netty.channel.Channel clientChannel, byte[] data) Called by the node-sideForwardingListenerto write a binary frame directly to the client channel, bypassingMessageOutboundConverter.
-