@Override public void serialize(FlowRemovedMessage message, ByteBuf outBuffer) { ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeLong(message.getCookie().longValue()); outBuffer.writeShort(message.getPriority()); outBuffer.writeByte(message.getReason().getIntValue()); outBuffer.writeByte(message.getTableId().getValue().byteValue()); outBuffer.writeInt(message.getDurationSec().intValue()); outBuffer.writeInt(message.getDurationNsec().intValue()); outBuffer.writeShort(message.getIdleTimeout()); outBuffer.writeShort(message.getHardTimeout()); outBuffer.writeLong(message.getPacketCount().longValue()); outBuffer.writeLong(message.getByteCount().longValue()); OFSerializer<Match> matchSerializer = registry.<Match, OFSerializer<Match>>getSerializer( new MessageTypeKey<>(message.getVersion(), Match.class)); matchSerializer.serialize(message.getMatch(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }
/** * Transforms POJO message into ByteBuf * * @param version version used for encoding received message * @param out ByteBuf for storing and sending transformed message * @param message POJO message */ public void messageToBuffer(short version, ByteBuf out, DataObject message) { OFSerializer<DataObject> serializer = registry.getSerializer(new MessageTypeKey<>(version, message.getImplementedInterface())); serializer.serialize(message, out); }