final int requestNumber = reader.readInt();
return Packet.isEnd(requestNumber) ? Packet.END : new Packet(requestNumber, (Message)messageSerializer.read(reader));
}
@Override public void write(final Object value, final Writer writer) throws Exception {
final Packet packet = (Packet)value;
if (packet.isEnd()) {
writer.writeInt(Packet.END_REQUEST_NUMBER);
} else {
writer.writeInt(packet.requestNumber());
messageSerializer.write(packet.message(), writer);
}
}