Class NettyWebSocketServerChannelHandler
java.lang.Object
io.netty5.channel.SimpleChannelInboundHandler<io.netty5.handler.codec.http.websocketx.WebSocketFrame>
eu.cloudnetservice.driver.network.netty.http.NettyWebSocketServerChannelHandler
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
@Internal
final class NettyWebSocketServerChannelHandler
extends io.netty5.channel.SimpleChannelInboundHandler<io.netty5.handler.codec.http.websocketx.WebSocketFrame>
The default netty based handler for web socket messages.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final eu.cloudnetservice.common.log.Loggerprivate final NettyWebSocketServerChannel -
Constructor Summary
ConstructorsConstructorDescriptionNettyWebSocketServerChannelHandler(@NonNull NettyWebSocketServerChannel webSocketServerChannel) Constructs a new web socket server handler instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelExceptionCaught(@NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull Throwable cause) voidchannelInactive(@NonNull io.netty5.channel.ChannelHandlerContext ctx) voidchannelReadComplete(@NonNull io.netty5.channel.ChannelHandlerContext ctx) private voidinvoke0(@NonNull WebSocketFrameType type, @NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame webSocketFrame) Invokes all handlers when a web socket frame was received.protected voidmessageReceived(@NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame webSocketFrame) private byte[]readContentFromWebSocketFrame(@NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame frame) Converts the body of a web socket frame to a byte array.Methods inherited from class io.netty5.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelInboundEvent, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
-
Field Details
-
LOGGER
private static final eu.cloudnetservice.common.log.Logger LOGGER -
webSocketServerChannel
-
-
Constructor Details
-
NettyWebSocketServerChannelHandler
public NettyWebSocketServerChannelHandler(@NonNull @NonNull NettyWebSocketServerChannel webSocketServerChannel) Constructs a new web socket server handler instance.- Parameters:
webSocketServerChannel- the wrapped web socket channel.- Throws:
NullPointerException- if the channel to wrap is null.
-
-
Method Details
-
channelExceptionCaught
-
channelReadComplete
-
channelInactive
-
messageReceived
protected void messageReceived(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame webSocketFrame) - Specified by:
messageReceivedin classio.netty5.channel.SimpleChannelInboundHandler<io.netty5.handler.codec.http.websocketx.WebSocketFrame>
-
invoke0
private void invoke0(@NonNull @NonNull WebSocketFrameType type, @NonNull @NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame webSocketFrame) Invokes all handlers when a web socket frame was received.- Parameters:
type- the type of frame received.webSocketFrame- the actual frame which was received.- Throws:
NullPointerException- if either the given type of frame is null.
-
readContentFromWebSocketFrame
private byte[] readContentFromWebSocketFrame(@NonNull @NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame frame) Converts the body of a web socket frame to a byte array.- Parameters:
frame- the received frame to read the body from.- Returns:
- the body of the frame, in bytes.
- Throws:
NullPointerException- if the given frame is null.
-