private static Guid ReadSubscribeResponse(ClientMessage responseMessage, object state)
        {
            var sstate = ToSafeState <MapSubscriptionState>(state);

            return(sstate.Mode switch
            {
                0 => MultiMapAddEntryListenerCodec.DecodeResponse(responseMessage).Response,
                1 => MultiMapAddEntryListenerToKeyCodec.DecodeResponse(responseMessage).Response,
                _ => throw new NotSupportedException()
            });
        public virtual string AddEntryListener(IEntryListener <K, V> listener, K key, bool includeValue)
        {
            var keyData = ToData(key);
            var request = MultiMapAddEntryListenerToKeyCodec.EncodeRequest(GetName(), keyData, includeValue);

            DistributedEventHandler handler =
                eventData => MultiMapAddEntryListenerToKeyCodec.AbstractEventHandler.Handle(eventData,
                                                                                            (thekey, value, oldValue, mergingValue, type, uuid, entries) =>
                                                                                            OnEntryEvent(thekey, value, oldValue, mergingValue, (EntryEventType)type, uuid, entries, includeValue, listener)
                                                                                            );

            return(Listen(request, message => MultiMapAddEntryListenerToKeyCodec.DecodeResponse(message).response, handler));
        }
Beispiel #3
0
        public virtual string AddEntryListener(IEntryListener <TKey, TValue> listener, TKey key, bool includeValue)
        {
            var listenerAdapter =
                EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, GetContext().GetSerializationService());

            var keyData = ToData(key);
            var request = MultiMapAddEntryListenerToKeyCodec.EncodeRequest(GetName(), keyData, includeValue, IsSmart());

            DistributedEventHandler handler =
                eventData => MultiMapAddEntryListenerToKeyCodec.EventHandler.HandleEvent(eventData,
                                                                                         (k, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(k, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

            return(RegisterListener(request, message => MultiMapAddEntryListenerToKeyCodec.DecodeResponse(message).response,
                                    id => MultiMapRemoveEntryListenerCodec.EncodeRequest(GetName(), id), handler));
        }