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 Details

    • LOGGER

      private static final eu.cloudnetservice.common.log.Logger LOGGER
    • webSocketServerChannel

      private final NettyWebSocketServerChannel 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

      public void channelExceptionCaught(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull Throwable cause)
    • channelReadComplete

      public void channelReadComplete(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx)
    • channelInactive

      public void channelInactive(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx)
    • messageReceived

      protected void messageReceived(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull io.netty5.handler.codec.http.websocketx.WebSocketFrame webSocketFrame)
      Specified by:
      messageReceived in class io.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.