Package org.mockserver.mock.action.http
Class BidirectionalWebSocketFrameHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
org.mockserver.mock.action.http.BidirectionalWebSocketFrameHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class BidirectionalWebSocketFrameHandler
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
Installed after a WebSocket handshake when the HttpWebSocketResponse has matchers.
Evaluates incoming frames against the matcher list in order; first match sends its responses.
Inbound breakpoints (A1e): when an INBOUND_STREAM breakpoint matcher is registered and
inbound stream ID is configured, incoming WebSocket frames are parked in the
StreamFrameBreakpointRegistry before matcher evaluation. The frame bytes are copied
to byte[] at park time and the original WebSocketFrame is released immediately
(this handler uses super(false) — no auto-release, so we manage the lifecycle). On
resume, a new frame is reconstructed from the captured/modified bytes.
Backpressure: while a frame is parked, autoRead is set to false
on the channel, preventing further inbound frames from being read. On resume,
autoRead is restored and ctx.read() is called.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCallback interface for sending response frames to the client.Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionBidirectionalWebSocketFrameHandler(List<WebSocketMessageMatcher> matchers, BidirectionalWebSocketFrameHandler.FrameSender frameSender) Original constructor — no inbound breakpoint support (backward compatible).BidirectionalWebSocketFrameHandler(List<WebSocketMessageMatcher> matchers, BidirectionalWebSocketFrameHandler.FrameSender frameSender, Configuration configuration, String inboundStreamId, WebSocketClientRegistry webSocketClientRegistry) Deprecated.use the constructor that accepts inboundBreakpointClientId and inboundBreakpointIdBidirectionalWebSocketFrameHandler(List<WebSocketMessageMatcher> matchers, BidirectionalWebSocketFrameHandler.FrameSender frameSender, Configuration configuration, String inboundStreamId, WebSocketClientRegistry webSocketClientRegistry, String inboundBreakpointClientId, String inboundBreakpointId) Constructor with inbound breakpoint support and pre-resolved breakpoint identity. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) protected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.websocketx.WebSocketFrame frame) Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, 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
-
BidirectionalWebSocketFrameHandler
public BidirectionalWebSocketFrameHandler(List<WebSocketMessageMatcher> matchers, BidirectionalWebSocketFrameHandler.FrameSender frameSender) Original constructor — no inbound breakpoint support (backward compatible). -
BidirectionalWebSocketFrameHandler
public BidirectionalWebSocketFrameHandler(List<WebSocketMessageMatcher> matchers, BidirectionalWebSocketFrameHandler.FrameSender frameSender, Configuration configuration, String inboundStreamId, WebSocketClientRegistry webSocketClientRegistry) Deprecated.use the constructor that accepts inboundBreakpointClientId and inboundBreakpointIdConstructor with inbound breakpoint support (performs its own findMatch for backward compatibility). -
BidirectionalWebSocketFrameHandler
public BidirectionalWebSocketFrameHandler(List<WebSocketMessageMatcher> matchers, BidirectionalWebSocketFrameHandler.FrameSender frameSender, Configuration configuration, String inboundStreamId, WebSocketClientRegistry webSocketClientRegistry, String inboundBreakpointClientId, String inboundBreakpointId) Constructor with inbound breakpoint support and pre-resolved breakpoint identity.- Parameters:
matchers- the matcher list for bidirectional matchingframeSender- callback for sending response framesconfiguration- the active server configuration (null to disable inbound breakpoints)inboundStreamId- the stream ID for inbound breakpoints (null to disable)webSocketClientRegistry- the per-server WS registry for callback dispatch (null to disable WS dispatch)inboundBreakpointClientId- the matched inbound breakpoint's owning clientId (from outer caller)inboundBreakpointId- the matched inbound breakpoint's id (from outer caller)
-
-
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>
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-