public void readFrom(DataInput in) throws Exception { type = in.readByte(); switch (type) { case DATA: seqno = Bits.readLong(in); conn_id = in.readShort(); first = in.readBoolean(); break; case ACK: seqno = Bits.readLong(in); conn_id = in.readShort(); break; case SEND_FIRST_SEQNO: seqno = Bits.readLong(in); break; } }
public void writeTo(DataOutput out) throws Exception { out.writeByte(type); switch (type) { case DATA: Bits.writeLong(seqno, out); out.writeShort(conn_id); out.writeBoolean(first); break; case ACK: Bits.writeLong(seqno, out); out.writeShort(conn_id); break; case SEND_FIRST_SEQNO: Bits.writeLong(seqno, out); break; } }
public final int size() { int retval = Global.BYTE_SIZE; // type switch (type) { case DATA: retval += Bits.size(seqno) // seqno + Global.SHORT_SIZE // conn_id + Global.BYTE_SIZE; // first break; case ACK: retval += Bits.size(seqno) + Global.SHORT_SIZE; // conn_id break; case SEND_FIRST_SEQNO: retval += Bits.size(seqno); break; } return retval; }
public int size() { return Global.BYTE_SIZE + Bits.size(seqno) + Global.BYTE_SIZE; // type + seqno + flush_ack }
public void readFrom(DataInput in) throws Exception { type = in.readByte(); seqno = Bits.readLong(in); flush_ack = in.readBoolean(); }
public void writeTo(DataOutput out) throws Exception { out.writeByte(type); Bits.writeLong(seqno, out); out.writeBoolean(flush_ack); }