Class Packet
- java.lang.Object
-
- de.dytanic.cloudnet.driver.network.protocol.Packet
-
- All Implemented Interfaces:
IPacket
- Direct Known Subclasses:
PacketClientAuthorization,PacketClientServerChannelMessage,PacketClientServerServiceInfoPublisher,PacketServerSetGlobalLogLevel,PacketServerUpdatePermissions
public class Packet extends java.lang.Object implements IPacket
The default simple implementation of the IPacket interface. You can create with the constructor all new packets or use the class as superclass from an another for specific constructor usage.All packets require a channel, header and a body.
The channel id is the id from that the listeners should be filter The header has the specify information or the data that is important The body has binary packet information like for files, or zip compressed data
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bodyprotected intchannelstatic byte[]EMPTY_PACKET_BYTE_ARRAYAn one length size byte[] for empty packet bodiesprotected de.dytanic.cloudnet.common.document.gson.JsonDocumentheaderprotected java.util.UUIDuniqueId
-
Constructor Summary
Constructors Constructor Description Packet()Packet(int channel, @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header)Packet(int channel, @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, byte[] body)Packet(int channel, @NotNull java.util.UUID uniqueId, @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, byte[] body)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getBody()Returns the packet body, for transport for extra data, like files or zip archives or something elseintgetChannel()Returns the channel id, in that the IPacketListenerRegistry class should the listeners work with that packetde.dytanic.cloudnet.common.document.gson.JsonDocumentgetHeader()The header, contain all important information from the packet, to specify the packet type as channel does and/or can has the data, which that are important to handle withjava.util.UUIDgetUniqueId()Returns the uuid of the packet.-
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.protocol.IPacket
isShowDebug
-
-
-
-
Field Detail
-
EMPTY_PACKET_BYTE_ARRAY
public static final byte[] EMPTY_PACKET_BYTE_ARRAY
An one length size byte[] for empty packet bodies
-
channel
protected int channel
-
uniqueId
protected java.util.UUID uniqueId
-
header
protected de.dytanic.cloudnet.common.document.gson.JsonDocument header
-
body
protected byte[] body
-
-
Constructor Detail
-
Packet
public Packet(int channel, @NotNull @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header)
-
Packet
public Packet(int channel, @NotNull @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, byte[] body)
-
Packet
public Packet(int channel, @NotNull @NotNull java.util.UUID uniqueId, @NotNull @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header, byte[] body)
-
Packet
public Packet()
-
-
Method Detail
-
getChannel
public int getChannel()
Description copied from interface:IPacketReturns the channel id, in that the IPacketListenerRegistry class should the listeners work with that packet- Specified by:
getChannelin interfaceIPacket- Returns:
- the channel id in that the packet is defined
-
getUniqueId
public java.util.UUID getUniqueId()
Description copied from interface:IPacketReturns the uuid of the packet. Each packet should has a own defined UUID instance, less the callback packets for synchronized messages between client and server- Specified by:
getUniqueIdin interfaceIPacket- Returns:
- the own uniqueId
-
getHeader
public de.dytanic.cloudnet.common.document.gson.JsonDocument getHeader()
Description copied from interface:IPacketThe header, contain all important information from the packet, to specify the packet type as channel does and/or can has the data, which that are important to handle withThe encoding should be UTF-8
-
getBody
public byte[] getBody()
Description copied from interface:IPacketReturns the packet body, for transport for extra data, like files or zip archives or something elseThe max length of the body can only be (Integer.MAX_VALUE - 1)
-
-