Пример #1
0
 /**
  * Reads a packet from the given buffer
  *
  * @param buf The buffer to read from
  * @return The packet that was read
  */
 @Override
 public Packet read(PacketBuffer buf) {
   PacketSpec spec = getSpec(buf.readInt());
   Packet packet = new Packet(new PacketBuilder(this, spec));
   packet.read(buf);
   return packet;
 }
Пример #2
0
 public Packet parsePacket(boolean isBlock) throws IOException {
   Packet packet = null;
   if (connection.getInputStream().available() > 0 || isBlock) {
     packet = new Packet();
     packet.read(connection);
     /** Вывод пакета в консоль */
     packet.dump(System.out);
   }
   return packet;
 }
Пример #3
0
 @Override
 void read(DataInputStream dis) throws IOException {
   super.read(dis);
   MyVersion = dis.readInt();
   ProtocolVersion = dis.readInt();
   int lu = dis.readInt();
   username = "";
   for (int i = 0; i < lu; i++) username += dis.readChar();
   lu = dis.readInt();
   password = "";
   for (int i = 0; i < lu; i++) password += dis.readChar();
 }