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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final AtomicLongprivate final longprivate final eu.cloudnetservice.driver.network.HostAndPortprivate final booleanprivate final eu.cloudnetservice.driver.network.NetworkChannelHandlerprivate final eu.cloudnetservice.driver.network.protocol.PacketListenerRegistryprotected final DefaultQueryPacketManagerprivate final eu.cloudnetservice.driver.network.HostAndPort -
Constructor Summary
ConstructorsConstructorDescriptionDefaultNetworkChannel(@NonNull eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry packetRegistry, @NonNull eu.cloudnetservice.driver.network.HostAndPort serverAddress, @NonNull eu.cloudnetservice.driver.network.HostAndPort clientAddress, boolean clientProvidedChannel, @NonNull eu.cloudnetservice.driver.network.NetworkChannelHandler handler) Constructs a new default network channel instance. -
Method Summary
Modifier and TypeMethodDescriptionlong@NonNull eu.cloudnetservice.driver.network.HostAndPortboolean@NonNull eu.cloudnetservice.driver.network.NetworkChannelHandlerhandler()@NonNull eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry@NonNull eu.cloudnetservice.driver.network.protocol.QueryPacketManager@NonNull CompletableFuture<eu.cloudnetservice.driver.network.protocol.Packet> sendQueryAsync(@NonNull eu.cloudnetservice.driver.network.protocol.Packet packet) @NonNull eu.cloudnetservice.driver.network.HostAndPortMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.network.NetworkChannel
active, close, closed, writeableMethods inherited from interface eu.cloudnetservice.driver.network.protocol.PacketSender
sendPacket, sendPacket, sendPacketSync
-
Field Details
-
CHANNEL_ID_COUNTER
-
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:
sendQueryAsyncin interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
channelId
public long channelId()- Specified by:
channelIdin interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
packetRegistry
-
queryPacketManager
-
serverAddress
-
clientAddress
-
clientProvidedChannel
public boolean clientProvidedChannel()- Specified by:
clientProvidedChannelin interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
handler
-