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
Fields inherited from class io.micronaut.http.netty.websocket.AbstractNettyWebSocketHandler
conversionService, ID, LOG, mediaTypeCodecRegistry, messageHandler, originatingRequest, pongHandler, subProtocol, uriVariables, webSocketBean, webSocketBinder, webSocketSessionRepository, webSocketVersion
-
Constructor Summary
ConstructorDescriptionNettyWebSocketClientHandler
(MutableHttpRequest<?> request, WebSocketBean<T> webSocketBean, io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker handshaker, RequestBinderRegistry requestBinderRegistry, MediaTypeCodecRegistry mediaTypeCodecRegistry, ConversionService conversionService) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) protected void
channelRead0
(io.netty.channel.ChannelHandlerContext ctx, Object msg) protected NettyWebSocketSession
createWebSocketSession
(io.netty.channel.ChannelHandlerContext ctx) Subclasses should implement to create the actualNettyWebSocketSession
.void
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) Argument<?>
final reactor.core.publisher.Mono<T>
Argument<?>
protected void
handleCloseReason
(io.netty.channel.ChannelHandlerContext ctx, CloseReason cr, boolean writeCloseReason) Used to close the session with a given reason.void
userEventTriggered
(io.netty.channel.ChannelHandlerContext ctx, Object evt) Methods inherited from class io.micronaut.http.netty.websocket.AbstractNettyWebSocketHandler
callOpenMethod, forwardErrorToUser, handlerRemoved, handleWebSocketFrame, instrumentPublisher, invokeExecutable, messageHandled, writeCloseFrameAndTerminate
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
Constructor Details
-
NettyWebSocketClientHandler
public NettyWebSocketClientHandler(MutableHttpRequest<?> request, WebSocketBean<T> webSocketBean, io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker handshaker, RequestBinderRegistry requestBinderRegistry, MediaTypeCodecRegistry mediaTypeCodecRegistry, 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 registryconversionService
- The conversionService
-
-
Method Details
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception - Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
getBodyArgument
- Specified by:
getBodyArgument
in classAbstractNettyWebSocketHandler
- Returns:
- The body argument for the message handler
-
getPongArgument
- Specified by:
getPongArgument
in classAbstractNettyWebSocketHandler
- Returns:
- The pong argument for the pong handler
-
getSession
- Specified by:
getSession
in classAbstractNettyWebSocketHandler
- Returns:
- The session
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
- Overrides:
channelRead0
in classAbstractNettyWebSocketHandler
-
createWebSocketSession
Description copied from class:AbstractNettyWebSocketHandler
Subclasses should implement to create the actualNettyWebSocketSession
.- Specified by:
createWebSocketSession
in classAbstractNettyWebSocketHandler
- Parameters:
ctx
- The context- Returns:
- The session
-
exceptionCaught
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classAbstractNettyWebSocketHandler
-
getHandshakeCompletedMono
-
handleCloseReason
protected void handleCloseReason(io.netty.channel.ChannelHandlerContext ctx, CloseReason cr, boolean writeCloseReason) Description copied from class:AbstractNettyWebSocketHandler
Used to close the session with a given reason.- Overrides:
handleCloseReason
in classAbstractNettyWebSocketHandler
- Parameters:
ctx
- The contextcr
- The reasonwriteCloseReason
- Whether to allow writing the close reason to the remote
-