public static ValueTask HandleEventAsync(ClientMessage clientMessage, Func <IData, Guid, Guid, long, object, ValueTask> handleIMapInvalidationEventAsync, Func <IList <IData>, IList <Guid>, IList <Guid>, IList <long>, object, ValueTask> handleIMapBatchInvalidationEventAsync, object state, ILoggerFactory loggerFactory)
        {
            using var iterator = clientMessage.GetEnumerator();
            var messageType = clientMessage.MessageType;

            if (messageType == EventIMapInvalidationMessageType)
            {
                var initialFrame  = iterator.Take();
                var sourceUuid    = initialFrame.Bytes.ReadGuidL(EventIMapInvalidationSourceUuidFieldOffset);
                var partitionUuid = initialFrame.Bytes.ReadGuidL(EventIMapInvalidationPartitionUuidFieldOffset);
                var sequence      = initialFrame.Bytes.ReadLongL(EventIMapInvalidationSequenceFieldOffset);
                var key           = CodecUtil.DecodeNullable(iterator, DataCodec.Decode);
                return(handleIMapInvalidationEventAsync(key, sourceUuid, partitionUuid, sequence, state));
            }
            if (messageType == EventIMapBatchInvalidationMessageType)
            {
                iterator.Take(); // empty initial frame
                var keys           = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode);
                var sourceUuids    = ListUUIDCodec.Decode(iterator);
                var partitionUuids = ListUUIDCodec.Decode(iterator);
                var sequences      = ListLongCodec.Decode(iterator);
                return(handleIMapBatchInvalidationEventAsync(keys, sourceUuids, partitionUuids, sequences, state));
            }
            loggerFactory.CreateLogger(typeof(EventHandler)).LogDebug("Unknown message type received on event handler :" + messageType);
            return(default);
            public static void HandleEvent(ClientMessage clientMessage, HandleIMapInvalidationEvent handleIMapInvalidationEvent, HandleIMapBatchInvalidationEvent handleIMapBatchInvalidationEvent)
            {
                var messageType = clientMessage.MessageType;
                var iterator    = clientMessage.GetIterator();

                if (messageType == EventIMapInvalidationMessageType)
                {
                    var   initialFrame  = iterator.Next();
                    Guid  sourceUuid    = DecodeGuid(initialFrame.Content, EventIMapInvalidationSourceUuidFieldOffset);
                    Guid  partitionUuid = DecodeGuid(initialFrame.Content, EventIMapInvalidationPartitionUuidFieldOffset);
                    long  sequence      = DecodeLong(initialFrame.Content, EventIMapInvalidationSequenceFieldOffset);
                    IData key           = CodecUtil.DecodeNullable(iterator, DataCodec.Decode);
                    handleIMapInvalidationEvent(key, sourceUuid, partitionUuid, sequence);
                    return;
                }
                if (messageType == EventIMapBatchInvalidationMessageType)
                {
                    //empty initial frame
                    iterator.Next();
                    IList <IData> keys           = ListMultiFrameCodec.Decode(iterator, DataCodec.Decode);
                    IList <Guid>  sourceUuids    = ListUUIDCodec.Decode(iterator);
                    IList <Guid>  partitionUuids = ListUUIDCodec.Decode(iterator);
                    IList <long>  sequences      = ListLongCodec.Decode(iterator);
                    handleIMapBatchInvalidationEvent(keys, sourceUuids, partitionUuids, sequences);
                    return;
                }
                Logger.GetLogger(typeof(EventHandler)).Finest("Unknown message type received on event handler :" + messageType);
            }