Interface NetworkChannel

All Superinterfaces:
PacketSender

public interface NetworkChannel extends PacketSender
A network channel represents an open connection from/to server.
Since:
4.0
  • Method Details

    • channelId

      long channelId()
      Get a unique numeric id of this channel. The ids are starting at 1.
      Returns:
      a unique numeric id of this channel.
    • serverAddress

      @NonNull @NonNull HostAndPort serverAddress()
      Get the server host from/to the channel is connected.
      Returns:
      the server address of the channel.
    • clientAddress

      @NonNull @NonNull HostAndPort clientAddress()
      Get the client host from/to the channel is connected.
      Returns:
      the client address of the channel.
    • handler

      Get the handler of this channel listening to all kind of operations on this channel.
      Returns:
      the listener for channel operations.
    • packetRegistry

      Get the packet listener registry responsible for this channel.
      Returns:
      the packet listener registry responsible for this channel.
    • queryPacketManager

      @NonNull @NonNull QueryPacketManager queryPacketManager()
      Get the query packet manager of this channel.
      Returns:
      the query packet manager of this channel.
    • clientProvidedChannel

      boolean clientProvidedChannel()
      Get if this client is opened by a client rather than a server.
      Returns:
      true if this channel was opened by a client, false otherwise.
    • sendQueryAsync

      Converts and sends the given packet as a query into this channel, returning a future either completed with the response to the query or an exception if no response to the packet was received in time.
      Parameters:
      packet - the packet to send as a query.
      Returns:
      a future completed with the result of the query or an exception in case of a timeout.
      Throws:
      NullPointerException - if the given packet is null.
    • writeable

      boolean writeable()
      Get if the underlying channel is currently writeable and will perform writes to the channel immediately.
      Returns:
      true if the channel can instantly process i/o requests, false otherwise.
    • active

      boolean active()
      Get if the underlying channel is still active and therefore connected.
      Returns:
      true if the channel is connected and active, false otherwise.
    • closed

      boolean closed()
      Get if this channel was marked as closed.
      Returns:
      if this channel was marked as closed.
    • close

      void close()
      Requests the close of the channel, flushing all outbound i/o requests before. After a channel was closed it cannot be used again.