Class Packet

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] body  
      protected int channel  
      static byte[] EMPTY_PACKET_BYTE_ARRAY
      An one length size byte[] for empty packet bodies
      protected de.dytanic.cloudnet.common.document.gson.JsonDocument header  
      protected java.util.UUID uniqueId  
    • 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 else
      int getChannel()
      Returns the channel id, in that the IPacketListenerRegistry class should the listeners work with that packet
      de.dytanic.cloudnet.common.document.gson.JsonDocument getHeader()
      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 with
      java.util.UUID getUniqueId()
      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: IPacket
        Returns the channel id, in that the IPacketListenerRegistry class should the listeners work with that packet
        Specified by:
        getChannel in interface IPacket
        Returns:
        the channel id in that the packet is defined
      • getUniqueId

        public java.util.UUID getUniqueId()
        Description copied from interface: IPacket
        Returns 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:
        getUniqueId in interface IPacket
        Returns:
        the own uniqueId
      • getHeader

        public de.dytanic.cloudnet.common.document.gson.JsonDocument getHeader()
        Description copied from interface: IPacket
        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 with

        The encoding should be UTF-8

        Specified by:
        getHeader in interface IPacket
        Returns:
        the header as JsonDocument instance from this packet
      • getBody

        public byte[] getBody()
        Description copied from interface: IPacket
        Returns the packet body, for transport for extra data, like files or zip archives or something else

        The max length of the body can only be (Integer.MAX_VALUE - 1)

        Specified by:
        getBody in interface IPacket
        Returns:
        the body as byte array in bytes