Class DefaultNetworkChannel
- java.lang.Object
-
- de.dytanic.cloudnet.driver.network.DefaultNetworkChannel
-
- All Implemented Interfaces:
INetworkChannel,IPacketSender,java.lang.AutoCloseable
- Direct Known Subclasses:
NettyNetworkChannel
public abstract class DefaultNetworkChannel extends java.lang.Object implements INetworkChannel
-
-
Constructor Summary
Constructors Constructor Description DefaultNetworkChannel(IPacketListenerRegistry packetRegistry, HostAndPort serverAddress, HostAndPort clientAddress, boolean clientProvidedChannel, INetworkChannelHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetChannelId()Returns the unique channelId.HostAndPortgetClientAddress()Returns the client address from this channelINetworkChannelHandlergetHandler()Returns the networkChannelHandler from this channelIPacketListenerRegistrygetPacketRegistry()Returns the own packet listener registry.HostAndPortgetServerAddress()Returns the server address from this channelbooleanisClientProvidedChannel()Returns that, the channel based of the client site connectionde.dytanic.cloudnet.common.concurrent.ITask<IPacket>registerQueryResponseHandler(java.util.UUID uniqueId)de.dytanic.cloudnet.common.concurrent.ITask<ChunkedQueryResponse>sendChunkedPacketQuery(@NotNull IPacket packet)booleansendChunkedPackets(@NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, @NotNull java.io.InputStream inputStream, int channel)booleansendChunkedPackets(@NotNull java.util.UUID uniqueId, @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, @NotNull java.io.InputStream inputStream, int channel)booleansendChunkedPacketsResponse(@NotNull java.util.UUID uniqueId, @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, @NotNull java.io.InputStream inputStream)voidsendPacket(@NotNull IPacket... packets)Transport packet instances into the network to the receiver.IPacketsendQuery(@NotNull IPacket packet)de.dytanic.cloudnet.common.concurrent.ITask<IPacket>sendQueryAsync(@NotNull IPacket packet)voidsetHandler(INetworkChannelHandler handler)Sets the channel handler for the channels.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.dytanic.cloudnet.driver.network.INetworkChannel
isActive, isWriteable
-
Methods inherited from interface de.dytanic.cloudnet.driver.network.protocol.IPacketSender
sendPacket, sendPacketSync, sendPacketSync
-
-
-
-
Constructor Detail
-
DefaultNetworkChannel
public DefaultNetworkChannel(IPacketListenerRegistry packetRegistry, HostAndPort serverAddress, HostAndPort clientAddress, boolean clientProvidedChannel, INetworkChannelHandler handler)
-
-
Method Detail
-
sendPacket
public void sendPacket(@NotNull @NotNull IPacket... packets)Description copied from interface:IPacketSenderTransport packet instances into the network to the receiver. The receiver will handle the packets if he knows the channel and has listeners for the channelA packet are doesn't allow to be null All elements should be checked that be not null and send after that
- Specified by:
sendPacketin interfaceIPacketSender- Parameters:
packets- the packets, which should transport into the network
-
sendQueryAsync
public de.dytanic.cloudnet.common.concurrent.ITask<IPacket> sendQueryAsync(@NotNull @NotNull IPacket packet)
- Specified by:
sendQueryAsyncin interfaceINetworkChannel
-
sendQuery
public IPacket sendQuery(@NotNull @NotNull IPacket packet)
- Specified by:
sendQueryin interfaceINetworkChannel
-
registerQueryResponseHandler
public de.dytanic.cloudnet.common.concurrent.ITask<IPacket> registerQueryResponseHandler(java.util.UUID uniqueId)
- Specified by:
registerQueryResponseHandlerin interfaceINetworkChannel
-
sendChunkedPacketQuery
public de.dytanic.cloudnet.common.concurrent.ITask<ChunkedQueryResponse> sendChunkedPacketQuery(@NotNull @NotNull IPacket packet)
- Specified by:
sendChunkedPacketQueryin interfaceINetworkChannel
-
sendChunkedPackets
public boolean sendChunkedPackets(@NotNull @NotNull java.util.UUID uniqueId, @NotNull @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, @NotNull @NotNull java.io.InputStream inputStream, int channel) throws java.io.IOException- Specified by:
sendChunkedPacketsin interfaceINetworkChannel- Throws:
java.io.IOException
-
sendChunkedPacketsResponse
public boolean sendChunkedPacketsResponse(@NotNull @NotNull java.util.UUID uniqueId, @NotNull @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, @NotNull @NotNull java.io.InputStream inputStream) throws java.io.IOException- Specified by:
sendChunkedPacketsResponsein interfaceINetworkChannel- Throws:
java.io.IOException
-
sendChunkedPackets
public boolean sendChunkedPackets(@NotNull @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, @NotNull @NotNull java.io.InputStream inputStream, int channel) throws java.io.IOException- Specified by:
sendChunkedPacketsin interfaceINetworkChannel- Throws:
java.io.IOException
-
getChannelId
public long getChannelId()
Description copied from interface:INetworkChannelReturns the unique channelId. The Channel Id begins with 1 and ends with Long.MAX_VALUE- Specified by:
getChannelIdin interfaceINetworkChannel
-
getPacketRegistry
public IPacketListenerRegistry getPacketRegistry()
Description copied from interface:INetworkChannelReturns the own packet listener registry. The packetRegistry is a sub registry of the network component packet listener registry- Specified by:
getPacketRegistryin interfaceINetworkChannel
-
getServerAddress
public HostAndPort getServerAddress()
Description copied from interface:INetworkChannelReturns the server address from this channel- Specified by:
getServerAddressin interfaceINetworkChannel
-
getClientAddress
public HostAndPort getClientAddress()
Description copied from interface:INetworkChannelReturns the client address from this channel- Specified by:
getClientAddressin interfaceINetworkChannel
-
isClientProvidedChannel
public boolean isClientProvidedChannel()
Description copied from interface:INetworkChannelReturns that, the channel based of the client site connection- Specified by:
isClientProvidedChannelin interfaceINetworkChannel
-
getHandler
public INetworkChannelHandler getHandler()
Description copied from interface:INetworkChannelReturns the networkChannelHandler from this channel- Specified by:
getHandlerin interfaceINetworkChannel
-
setHandler
public void setHandler(INetworkChannelHandler handler)
Description copied from interface:INetworkChannelSets the channel handler for the channels. That is important for the handling of receiving packets or channel closing and connect handler- Specified by:
setHandlerin interfaceINetworkChannel- Parameters:
handler- the handler, that should handle this channel
-
-