code: public static void serializeTo( AbstractPacket packet , RawDataBuffer out )
      {
          out.writeByte(packet.getType());
          packet.serializeTo(out);
      }
docs: Serialize a packet to the given output stream