Class DefaultNetworkChannel

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

public abstract class DefaultNetworkChannel extends Object implements eu.cloudnetservice.driver.network.NetworkChannel
The default abstract implementation of a network channel.
Since:
4.0
  • Field Details

    • CHANNEL_ID_COUNTER

      private static final AtomicLong CHANNEL_ID_COUNTER
    • queryPacketManager

      protected final DefaultQueryPacketManager queryPacketManager
    • packetRegistry

      private final eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry packetRegistry
    • serverAddress

      private final eu.cloudnetservice.driver.network.HostAndPort serverAddress
    • clientAddress

      private final eu.cloudnetservice.driver.network.HostAndPort clientAddress
    • clientProvidedChannel

      private final boolean clientProvidedChannel
    • handler

      private final eu.cloudnetservice.driver.network.NetworkChannelHandler handler
    • channelId

      private final long channelId
  • Constructor Details

    • DefaultNetworkChannel

      public DefaultNetworkChannel(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry packetRegistry, @NonNull @NonNull eu.cloudnetservice.driver.network.HostAndPort serverAddress, @NonNull @NonNull eu.cloudnetservice.driver.network.HostAndPort clientAddress, boolean clientProvidedChannel, @NonNull @NonNull eu.cloudnetservice.driver.network.NetworkChannelHandler handler)
      Constructs a new default network channel instance.
      Parameters:
      packetRegistry - the packet registry to use for the channel.
      serverAddress - the associated server address for the connection.
      clientAddress - the associated client address for the connection.
      clientProvidedChannel - true if this channel was opened by a client, false otherwise.
      handler - the handler to post underlying network events to.
      Throws:
      NullPointerException - if one of the given arguments is null.
  • Method Details

    • sendQueryAsync

      @NonNull public @NonNull CompletableFuture<eu.cloudnetservice.driver.network.protocol.Packet> sendQueryAsync(@NonNull @NonNull eu.cloudnetservice.driver.network.protocol.Packet packet)
      Specified by:
      sendQueryAsync in interface eu.cloudnetservice.driver.network.NetworkChannel
    • channelId

      public long channelId()
      Specified by:
      channelId in interface eu.cloudnetservice.driver.network.NetworkChannel
    • packetRegistry

      @NonNull public @NonNull eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry packetRegistry()
      Specified by:
      packetRegistry in interface eu.cloudnetservice.driver.network.NetworkChannel
    • queryPacketManager

      @NonNull public @NonNull eu.cloudnetservice.driver.network.protocol.QueryPacketManager queryPacketManager()
      Specified by:
      queryPacketManager in interface eu.cloudnetservice.driver.network.NetworkChannel
    • serverAddress

      @NonNull public @NonNull eu.cloudnetservice.driver.network.HostAndPort serverAddress()
      Specified by:
      serverAddress in interface eu.cloudnetservice.driver.network.NetworkChannel
    • clientAddress

      @NonNull public @NonNull eu.cloudnetservice.driver.network.HostAndPort clientAddress()
      Specified by:
      clientAddress in interface eu.cloudnetservice.driver.network.NetworkChannel
    • clientProvidedChannel

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

      @NonNull public @NonNull eu.cloudnetservice.driver.network.NetworkChannelHandler handler()
      Specified by:
      handler in interface eu.cloudnetservice.driver.network.NetworkChannel