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.

  • 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 inboundBreakpointId
      Constructor 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 matching
      frameSender - callback for sending response frames
      configuration - 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:
      channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.websocketx.WebSocketFrame>
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception