package ch.ethz.syslab.telesto.common.protocol; import java.nio.ByteBuffer; import ch.ethz.syslab.telesto.common.protocol.handler.PacketProcessingException; import ch.ethz.syslab.telesto.common.protocol.handler.ProtocolHandler; /* * Do not edit this file! * * Edit the template at tools/protocol/telesto/templates/packet.java instead. */ public class IdentifyClientResponsePacket extends Packet { public byte mode; public String name; public IdentifyClientResponsePacket() { } public IdentifyClientResponsePacket(byte mode, String name) { this.mode = mode; this.name = name; } public IdentifyClientResponsePacket(int packetId, byte mode, String name) { this.packetId = packetId; this.mode = mode; this.name = name; } @Override public byte methodId() { return 20; } @Override public void emit(ByteBuffer buffer) { int lengthIndex = buffer.position(); buffer.position(lengthIndex + 2); buffer.put(methodId()); buffer.putInt(packetId); buffer.put(mode); putString(buffer, name); buffer.putShort(lengthIndex, (short) (buffer.position() - lengthIndex - 2)); } @Override public void parse(ByteBuffer buffer) { packetId = buffer.getInt(); mode = buffer.get(); name = getString(buffer); } @Override public IdentifyClientResponsePacket newInstance() { return new IdentifyClientResponsePacket(); } public Packet getHandled(ProtocolHandler handler) throws PacketProcessingException { return handler.handle((IdentifyClientResponsePacket) this); } public String toString() { return "IdentifyClientResponsePacket"; } }