Class NettyWebSocketClientHandler<T>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<Object>
io.micronaut.http.netty.websocket.AbstractNettyWebSocketHandler
io.micronaut.http.client.netty.websocket.NettyWebSocketClientHandler<T>
- Type Parameters:
T- The type emitted.
- All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
Handler for WebSocket clients.
- Since:
- 1.0
- Author:
- graemerocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionNettyWebSocketClientHandler(MutableHttpRequest<?> request, WebSocketBean<T> webSocketBean, io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker handshaker, RequestBinderRegistry requestBinderRegistry, MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry, ConversionService conversionService) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) protected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, Object msg) protected NettyWebSocketSessioncreateWebSocketSession(io.netty.channel.ChannelHandlerContext ctx) Subclasses should implement to create the actualNettyWebSocketSession.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Argument<?> final reactor.core.publisher.Mono<T> Argument<?> protected voidhandleCloseReason(io.netty.channel.ChannelHandlerContext ctx, CloseReason cr, boolean writeCloseReason) Used to close the session with a given reason.voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) Methods inherited from class AbstractNettyWebSocketHandler
callOpenMethod, forwardErrorToUser, handlerRemoved, handleWebSocketFrame, instrumentPublisher, invokeExecutable, messageHandled, writeCloseFrameAndTerminateMethods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
NettyWebSocketClientHandler
public NettyWebSocketClientHandler(MutableHttpRequest<?> request, WebSocketBean<T> webSocketBean, io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker handshaker, RequestBinderRegistry requestBinderRegistry, MediaTypeCodecRegistry mediaTypeCodecRegistry, MessageBodyHandlerRegistry messageBodyHandlerRegistry, ConversionService conversionService) Default constructor.- Parameters:
request- The originating request that created the WebSocket.webSocketBean- The WebSocket client bean.handshaker- The handshakerrequestBinderRegistry- The request binder registrymediaTypeCodecRegistry- The media type codec registrymessageBodyHandlerRegistry- The handler registryconversionService- The conversionService
-
-
Method Details
-
userEventTriggered
-
getBodyArgument
- Specified by:
getBodyArgumentin classAbstractNettyWebSocketHandler- Returns:
- The body argument for the message handler
-
getPongArgument
- Specified by:
getPongArgumentin classAbstractNettyWebSocketHandler- Returns:
- The pong argument for the pong handler
-
getSession
- Specified by:
getSessionin classAbstractNettyWebSocketHandler- Returns:
- The session
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
- Overrides:
channelRead0in classAbstractNettyWebSocketHandler
-
createWebSocketSession
Description copied from class:AbstractNettyWebSocketHandlerSubclasses should implement to create the actualNettyWebSocketSession.- Specified by:
createWebSocketSessionin classAbstractNettyWebSocketHandler- Parameters:
ctx- The context- Returns:
- The session
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classAbstractNettyWebSocketHandler
-
getHandshakeCompletedMono
-
handleCloseReason
protected void handleCloseReason(io.netty.channel.ChannelHandlerContext ctx, CloseReason cr, boolean writeCloseReason) Description copied from class:AbstractNettyWebSocketHandlerUsed to close the session with a given reason.- Overrides:
handleCloseReasonin classAbstractNettyWebSocketHandler- Parameters:
ctx- The contextcr- The reasonwriteCloseReason- Whether to allow writing the close reason to the remote
-