@Override
public Object fromBinary(ByteBuf buf, DatagramPacket datagram) {
byte type = buf.readByte();
SpecialSerializers.MessageSerializationUtil.MessageFields fields = SpecialSerializers.MessageSerializationUtil.msgFromBinary(buf);
switch (type) {
case DIS: {
byte portUpper = buf.readByte();
byte portLower = buf.readByte();
int udtPort = Ints.fromBytes((byte) 0, (byte) 0, portUpper, portLower);
return new DisambiguateConnection(new NettyAddress(datagram.sender()), new NettyAddress(datagram.recipient()), Transport.UDP, udtPort, fields.flag1);
}
case ACK: {
UUID id = (UUID) SpecialSerializers.UUIDSerializer.INSTANCE.fromBinary(buf, Optional.absent());
return new NotifyAck(new NettyAddress(datagram.sender()), new NettyAddress(datagram.recipient()), Transport.UDP, id);
}
case ACK_REQ: {
UUID id = (UUID) SpecialSerializers.UUIDSerializer.INSTANCE.fromBinary(buf, Optional.absent());
Msg msg = (Msg) Serializers.fromBinary(buf, datagram);
return new AckRequestMsg(msg, id);
}
}
return null;
}