@Internal public abstract class AbstractNettyWebSocketHandler extends io.netty.channel.SimpleChannelInboundHandler<Object>
Modifier and Type | Field and Description |
---|---|
static String |
ID
The id of the handler used when adding it to the Netty pipeline.
|
protected org.slf4j.Logger |
LOG |
protected MediaTypeCodecRegistry |
mediaTypeCodecRegistry |
protected MethodExecutionHandle<?,?> |
messageHandler |
protected HttpRequest<?> |
originatingRequest |
protected NettyRxWebSocketSession |
session |
protected Map<String,Object> |
uriVariables |
protected WebSocketBean<?> |
webSocketBean |
protected ArgumentBinderRegistry<WebSocketState> |
webSocketBinder |
protected WebSocketSessionRepository |
webSocketSessionRepository |
protected io.netty.handler.codec.http.websocketx.WebSocketVersion |
webSocketVersion |
Modifier | Constructor and Description |
---|---|
protected |
AbstractNettyWebSocketHandler(io.netty.channel.ChannelHandlerContext ctx,
RequestBinderRegistry binderRegistry,
MediaTypeCodecRegistry mediaTypeCodecRegistry,
WebSocketBean<?> webSocketBean,
HttpRequest<?> request,
Map<String,Object> uriVariables,
io.netty.handler.codec.http.websocketx.WebSocketVersion version,
WebSocketSessionRepository webSocketSessionRepository)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
protected abstract NettyRxWebSocketSession |
createWebSocketSession(io.netty.channel.ChannelHandlerContext ctx)
Subclasses should implement to create the actual
NettyRxWebSocketSession . |
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
Argument<?> |
getBodyArgument() |
NettyRxWebSocketSession |
getSession() |
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
handleWebSocketFrame(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.websocketx.WebSocketFrame msg)
Handles WebSocket frame request.
|
protected io.reactivex.Flowable<?> |
instrumentPublisher(io.netty.channel.ChannelHandlerContext ctx,
Object result)
Subclasses can override to customize publishers returned from message handlers.
|
protected Object |
invokeExecutable(BoundExecutable boundExecutable,
MethodExecutionHandle<?,?> messageHandler)
Invokes the given executable.
|
protected void |
messageHandled(io.netty.channel.ChannelHandlerContext ctx,
NettyRxWebSocketSession session,
Object message)
Method called once a message has been handled by the handler.
|
protected void |
writeCloseFrameAndTerminate(io.netty.channel.ChannelHandlerContext ctx,
CloseReason closeReason)
Writes the give close reason and terminates the session.
|
acceptInboundMessage, channelRead
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, isSharable
public static final String ID
protected final org.slf4j.Logger LOG
protected final ArgumentBinderRegistry<WebSocketState> webSocketBinder
protected final WebSocketBean<?> webSocketBean
protected final HttpRequest<?> originatingRequest
protected final MethodExecutionHandle<?,?> messageHandler
protected final NettyRxWebSocketSession session
protected final MediaTypeCodecRegistry mediaTypeCodecRegistry
protected final io.netty.handler.codec.http.websocketx.WebSocketVersion webSocketVersion
protected final WebSocketSessionRepository webSocketSessionRepository
protected AbstractNettyWebSocketHandler(io.netty.channel.ChannelHandlerContext ctx, RequestBinderRegistry binderRegistry, MediaTypeCodecRegistry mediaTypeCodecRegistry, WebSocketBean<?> webSocketBean, HttpRequest<?> request, Map<String,Object> uriVariables, io.netty.handler.codec.http.websocketx.WebSocketVersion version, WebSocketSessionRepository webSocketSessionRepository)
ctx
- The channel handler contextbinderRegistry
- The request binder registrymediaTypeCodecRegistry
- The codec registrywebSocketBean
- The websocket beanrequest
- The originating requesturiVariables
- The URI variablesversion
- The websocket version being usedwebSocketSessionRepository
- The web socket repository if they are supported (like on the server), null otherwisepublic Argument<?> getBodyArgument()
public NettyRxWebSocketSession getSession()
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) throws Exception
handlerRemoved
in interface io.netty.channel.ChannelHandler
handlerRemoved
in class io.netty.channel.ChannelHandlerAdapter
Exception
protected abstract NettyRxWebSocketSession createWebSocketSession(io.netty.channel.ChannelHandlerContext ctx)
NettyRxWebSocketSession
.ctx
- The contextprotected io.reactivex.Flowable<?> instrumentPublisher(io.netty.channel.ChannelHandlerContext ctx, Object result)
ctx
- The contextresult
- The resultprotected Object invokeExecutable(BoundExecutable boundExecutable, MethodExecutionHandle<?,?> messageHandler)
boundExecutable
- The bound executablemessageHandler
- The message handlerprotected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, Object msg)
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler<Object>
protected void handleWebSocketFrame(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.websocketx.WebSocketFrame msg)
ctx
- The contextmsg
- The frameprotected void messageHandled(io.netty.channel.ChannelHandlerContext ctx, NettyRxWebSocketSession session, Object message)
ctx
- The channel handler contextsession
- The sessionmessage
- The message that was handledprotected void writeCloseFrameAndTerminate(io.netty.channel.ChannelHandlerContext ctx, CloseReason closeReason)
ctx
- The contextcloseReason
- The reason