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 Summary
FieldsModifier and TypeFieldDescriptionprivate final io.netty5.channel.Channelprivate booleanFields inherited from class DefaultNetworkChannel
queryPacketManager -
Constructor Summary
ConstructorsConstructorDescriptionNettyNetworkChannel(@NonNull io.netty5.channel.Channel channel, @NonNull eu.cloudnetservice.driver.network.protocol.PacketListenerRegistry packetRegistry, @NonNull eu.cloudnetservice.driver.network.NetworkChannelHandler handler, @NonNull eu.cloudnetservice.driver.network.HostAndPort serverAddress, @NonNull eu.cloudnetservice.driver.network.HostAndPort clientAddress, boolean clientProvidedChannel) Constructs a new netty network channel instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanactive()voidclose()booleanclosed()(package private) voidCalled when the associated channel is closed.voidsendPacket(@NonNull eu.cloudnetservice.driver.network.protocol.Packet packet) voidsendPacket(@NonNull eu.cloudnetservice.driver.network.protocol.Packet... packets) voidsendPacketSync(@NonNull eu.cloudnetservice.driver.network.protocol.Packet packet) booleanMethods inherited from class DefaultNetworkChannel
channelId, clientAddress, clientProvidedChannel, handler, packetRegistry, queryPacketManager, sendQueryAsync, serverAddressMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.driver.network.NetworkChannel
channelId, clientAddress, clientProvidedChannel, handler, packetRegistry, queryPacketManager, sendQueryAsync, serverAddress
-
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
-
sendPacket
-
sendPacketSync
-
writeable
public boolean writeable()- Specified by:
writeablein interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
active
public boolean active()- Specified by:
activein interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
closed
public boolean closed()- Specified by:
closedin interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
close
public void close()- Specified by:
closein interfaceeu.cloudnetservice.driver.network.NetworkChannel
-
handleClose
-