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
- Author:
- graemerocher
-
Field Summary
-
Constructor Summary
ConstructorDescriptionNettyServerWebSocketUpgradeHandler
(NettyEmbeddedServices embeddedServices, WebSocketSessionRepository webSocketSessionRepository, ConversionService conversionService, NettyHttpServerConfiguration serverConfiguration) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpRequest request, PipeliningServerHandler.OutboundAccess outboundAccess) Handle a request.protected String
getWebSocketURL
(io.netty.channel.ChannelHandlerContext ctx, HttpRequest req) Obtains the web socket URL.protected io.netty.channel.ChannelFuture
handleHandshake
(io.netty.channel.ChannelHandlerContext ctx, NettyHttpRequest req, WebSocketBean<?> webSocketBean, MutableHttpResponse<?> response) Do the handshaking for WebSocket request.void
handleUnboundError
(Throwable cause) Handle an error that is not bound to a request, i.e.void
removed()
Called when the handler is removed.void
responseWritten
(Object attachment) Called roughly when a response has been written.void
setNext
(RoutingInBoundHandler next)
-
Field Details
-
ID
- See Also:
-
SCHEME_WEBSOCKET
- See Also:
-
SCHEME_SECURE_WEBSOCKET
- See Also:
-
COMPRESSION_HANDLER
- See Also:
-
-
Constructor Details
-
NettyServerWebSocketUpgradeHandler
public NettyServerWebSocketUpgradeHandler(NettyEmbeddedServices embeddedServices, WebSocketSessionRepository webSocketSessionRepository, ConversionService conversionService, NettyHttpServerConfiguration serverConfiguration) Default constructor.- Parameters:
embeddedServices
- The embedded server serviceswebSocketSessionRepository
- The websocket session repositoryconversionService
- The conversion serviceserverConfiguration
- 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 interfaceRequestHandler
- Parameters:
ctx
- The context this request came in onrequest
- The request, either aFullHttpRequest
or aStreamedHttpRequest
outboundAccess
- ThePipeliningServerHandler.OutboundAccess
to use for writing the response
-
handleUnboundError
Description copied from interface:RequestHandler
Handle an error that is not bound to a request, i.e. happens outside aStreamedHttpRequest
.- Specified by:
handleUnboundError
in interfaceRequestHandler
- Parameters:
cause
- The error
-
responseWritten
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 responsePublisher
has been fully consumed.
This is used for cleaning up the request.- Specified by:
responseWritten
in interfaceRequestHandler
- Parameters:
attachment
- Object passed toPipeliningServerHandler.OutboundAccess.attachment(Object)
-
handleHandshake
protected io.netty.channel.ChannelFuture handleHandshake(io.netty.channel.ChannelHandlerContext ctx, NettyHttpRequest req, WebSocketBean<?> webSocketBean, MutableHttpResponse<?> response) Do the handshaking for WebSocket request.- Parameters:
ctx
- The channel handler contextreq
- The requestwebSocketBean
- The web socket beanresponse
- The response- Returns:
- The channel future
-
getWebSocketURL
Obtains the web socket URL.- Parameters:
ctx
- The contextreq
- 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 interfaceRequestHandler
-
setNext
-