Class NettyNetworkChannel

java.lang.Object
eu.cloudnetservice.driver.impl.network.DefaultNetworkChannel
eu.cloudnetservice.driver.impl.network.netty.NettyNetworkChannel
All Implemented Interfaces:
eu.cloudnetservice.driver.network.NetworkChannel, eu.cloudnetservice.driver.network.protocol.PacketSender

public final class NettyNetworkChannel extends DefaultNetworkChannel implements eu.cloudnetservice.driver.network.NetworkChannel
The default netty based implementation of a network channel.
Since:
4.0
  • Field Details

    • channel

      private final io.netty5.channel.Channel channel
    • closed

      private volatile boolean closed
  • Constructor Details

    • NettyNetworkChannel

      public NettyNetworkChannel(@NonNull @NonNull io.netty5.channel.Channel channel, @NonNull @NonNull eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry packetRegistry, @NonNull @NonNull eu.cloudnetservice.driver.network.NetworkChannelHandler handler, @NonNull @NonNull eu.cloudnetservice.driver.network.HostAndPort serverAddress, @NonNull @NonNull eu.cloudnetservice.driver.network.HostAndPort clientAddress, boolean clientProvidedChannel)
      Constructs a new netty network channel instance.
      Parameters:
      channel - the netty channel to wrap.
      packetRegistry - the packet registry for this channel.
      handler - the handler to post events to.
      serverAddress - the server address to which the client connected.
      clientAddress - the client address which is assigned to the connection.
      clientProvidedChannel - true if the channel is handled by a server, false otherwise.
      Throws:
      NullPointerException - if one of the required constructor paramters is null.
  • Method Details

    • sendPacket

      public void sendPacket(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.Packet... packets)
      Specified by:
      sendPacket in interface eu.cloudnetservice.driver.network.protocol.PacketSender
    • sendPacket

      public void sendPacket(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.Packet packet)
      Specified by:
      sendPacket in interface eu.cloudnetservice.driver.network.protocol.PacketSender
    • sendPacketSync

      public void sendPacketSync(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.Packet packet)
      Specified by:
      sendPacketSync in interface eu.cloudnetservice.driver.network.protocol.PacketSender
    • writeable

      public boolean writeable()
      Specified by:
      writeable in interface eu.cloudnetservice.driver.network.NetworkChannel
    • active

      public boolean active()
      Specified by:
      active in interface eu.cloudnetservice.driver.network.NetworkChannel
    • closed

      public boolean closed()
      Specified by:
      closed in interface eu.cloudnetservice.driver.network.NetworkChannel
    • close

      public void close()
      Specified by:
      close in interface eu.cloudnetservice.driver.network.NetworkChannel
    • handleClose

      void handleClose() throws Exception
      Called when the associated channel is closed.
      Throws:
      Exception - if an exception occurs while posting the close event to the channel handler.