Class NettyServerWebSocketUpgradeHandler

java.lang.Object
io.micronaut.http.server.netty.websocket.NettyServerWebSocketUpgradeHandler
All Implemented Interfaces:
RequestHandler

@Internal public final class NettyServerWebSocketUpgradeHandler extends Object implements RequestHandler
Handles WebSocket upgrade requests.
Since:
1.0
  • Field Details

  • Constructor Details

    • NettyServerWebSocketUpgradeHandler

      public NettyServerWebSocketUpgradeHandler(NettyEmbeddedServices embeddedServices, io.micronaut.http.netty.websocket.WebSocketSessionRepository webSocketSessionRepository, io.micronaut.core.convert.ConversionService conversionService, NettyHttpServerConfiguration serverConfiguration)
      Default constructor.
      Parameters:
      embeddedServices - The embedded server services
      webSocketSessionRepository - The websocket session repository
      conversionService - The conversion service
      serverConfiguration - The server configuration
  • Method Details

    • accept

      public void accept(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpRequest request, PipeliningServerHandler.OutboundAccess outboundAccess)
      Description copied from interface: RequestHandler
      Handle a request.
      Specified by:
      accept in interface RequestHandler
      Parameters:
      ctx - The context this request came in on
      request - The request, either a FullHttpRequest or a StreamedHttpRequest
      outboundAccess - The PipeliningServerHandler.OutboundAccess to use for writing the response
    • handleUnboundError

      public void handleUnboundError(Throwable cause)
      Description copied from interface: RequestHandler
      Handle an error that is not bound to a request, i.e. happens outside of a StreamedHttpRequest.
      Specified by:
      handleUnboundError in interface RequestHandler
      Parameters:
      cause - The error
    • responseWritten

      public void responseWritten(Object attachment)
      Description copied from interface: RequestHandler
      Called roughly when a response has been written. In particular, it's called when the user is "done" with the response and has no way of adding further data. The bytes may not have been fully flushed yet, but e.g. the response Publisher has been fully consumed.
      This is used for cleaning up the request.
      Specified by:
      responseWritten in interface RequestHandler
      Parameters:
      attachment - Object passed to PipeliningServerHandler.OutboundAccess.attachment(Object)
    • handleHandshake

      protected io.netty.channel.ChannelFuture handleHandshake(io.netty.channel.ChannelHandlerContext ctx, NettyHttpRequest req, io.micronaut.websocket.context.WebSocketBean<?> webSocketBean, io.micronaut.http.MutableHttpResponse<?> response)
      Do the handshaking for WebSocket request.
      Parameters:
      ctx - The channel handler context
      req - The request
      webSocketBean - The web socket bean
      response - The response
      Returns:
      The channel future
    • getWebSocketURL

      protected String getWebSocketURL(io.netty.channel.ChannelHandlerContext ctx, io.micronaut.http.HttpRequest req)
      Obtains the web socket URL.
      Parameters:
      ctx - The context
      req - The request
      Returns:
      The socket URL
    • removed

      public void removed()
      Description copied from interface: RequestHandler
      Called when the handler is removed.
      Specified by:
      removed in interface RequestHandler
    • setNext

      public void setNext(RoutingInBoundHandler next)