Class Packet

    • 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 de.dytanic.cloudnet.common.document.gson.JsonDocument header, ProtocolBuffer body)  
      Packet​(int channel, @NotNull java.util.UUID uniqueId, @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header)  
      Packet​(int channel, @NotNull java.util.UUID uniqueId, @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, ProtocolBuffer body)  
      Packet​(int channel, ProtocolBuffer body)  
    • Field Detail

      • EMPTY_PACKET_BYTE_ARRAY

        public static final byte[] EMPTY_PACKET_BYTE_ARRAY
        An one length size byte[] for empty packet bodies
      • EMPTY

        public static final Packet EMPTY
      • creationMillis

        protected final long creationMillis
      • channel

        protected int channel
      • uniqueId

        protected java.util.UUID uniqueId
      • header

        protected de.dytanic.cloudnet.common.document.gson.JsonDocument header
    • 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​(int channel,
                      @NotNull
                      @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header,
                      ProtocolBuffer body)
      • Packet

        public Packet​(int channel,
                      @NotNull
                      @NotNull java.util.UUID uniqueId,
                      @NotNull
                      @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header)
      • Packet

        public Packet​(int channel,
                      @NotNull
                      @NotNull java.util.UUID uniqueId,
                      @NotNull
                      @NotNull de.dytanic.cloudnet.common.document.gson.JsonDocument header,
                      ProtocolBuffer body)
      • Packet

        public Packet()
    • Method Detail

      • createResponseFor

        public static Packet createResponseFor​(IPacket packet,
                                               de.dytanic.cloudnet.common.document.gson.JsonDocument header,
                                               ProtocolBuffer body)
      • createResponseFor

        public static Packet createResponseFor​(IPacket packet,
                                               de.dytanic.cloudnet.common.document.gson.JsonDocument header)
      • createResponseFor

        public static Packet createResponseFor​(IPacket packet)
      • 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

        @NotNull
        public @NotNull 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
      • getBuffer

        public ProtocolBuffer getBuffer()
        Description copied from interface: IPacket
        Returns the packet body, for transport for extra data, like files or zip archives or something else
        Specified by:
        getBuffer in interface IPacket
        Returns:
        the body as a ProtocolBuffer
      • getBodyAsArray

        public byte[] getBodyAsArray()
        Specified by:
        getBodyAsArray in interface IPacket
        Returns:
        the body as a byte array
      • getCreationMillis

        public long getCreationMillis()
        Specified by:
        getCreationMillis in interface IPacket
        Returns:
        the creation milliseconds of this packet