Class Packet

java.lang.Object
dev.forbit.server.abstracts.Packet
All Implemented Interfaces:
PacketInterface
Direct Known Subclasses:
GSONPacket, RawConnectionPacket, RawPacket

public abstract class Packet extends Object implements PacketInterface
Parent packet class. Defines common behaviour across packets.
  • Constructor Details

    • Packet

      public Packet()
  • Method Details

    • fillBuffer

      public abstract void fillBuffer(GMLOutputBuffer buffer)
      Fill the buffer with information you want to send to the client
      Parameters:
      buffer - the buffer with the header already included.
    • loadBuffer

      public abstract void loadBuffer(GMLInputBuffer buffer)
      Load information from the input buffer into the class to use
      Parameters:
      buffer - the input (header is already read.)
    • getBuffer

      public ByteBuffer getBuffer()
      Gets the byte buffer of the packet with the header included at the beginning.
      Specified by:
      getBuffer in interface PacketInterface
      Returns:
      ByteBuffer ready to be sent.
    • toString

      public String toString()
      Returns a GSON serialised string of the object
      Overrides:
      toString in class Object
      Returns:
      GSON string