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

            return(sstate.Mode switch
            {
                0 => MapAddEntryListenerCodec.DecodeResponse(responseMessage).Response,
                1 => MapAddEntryListenerToKeyCodec.DecodeResponse(responseMessage).Response,
                2 => MapAddEntryListenerWithPredicateCodec.DecodeResponse(responseMessage).Response,
                3 => MapAddEntryListenerToKeyWithPredicateCodec.DecodeResponse(responseMessage).Response,
                _ => throw new NotSupportedException()
            });
        public string AddEntryListener(IEntryListener <K, V> listener, bool includeValue)
        {
            var listenerFlags = GetListenerFlags(listener);
            var request       = MapAddEntryListenerCodec.EncodeRequest(GetName(), includeValue, listenerFlags, false);
            DistributedEventHandler handler =
                eventData => MapAddEntryListenerCodec.AbstractEventHandler.Handle(eventData,
                                                                                  (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener);
            });

            return(Listen(request, message => MapAddEntryListenerCodec.DecodeResponse(message).response, handler));
        }
Esempio n. 3
0
        public Guid AddEntryListener(MapListener listener, bool includeValue)
        {
            var listenerAdapter = EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, Client.SerializationService);

            var listenerFlags = (int)listenerAdapter.ListenerFlags;
            var request       = MapAddEntryListenerCodec.EncodeRequest(Name, includeValue, listenerFlags, IsSmart());
            DistributedEventHandler handler = eventData => MapAddEntryListenerCodec.EventHandler.HandleEvent(eventData,
                                                                                                             (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

            return(RegisterListener(request, message => MapAddEntryListenerCodec.DecodeResponse(message).Response,
                                    id => MapRemoveEntryListenerCodec.EncodeRequest(Name, id), handler));
        }
        public string AddEntryListener(IEntryListener <K, V> listener, IPredicate <K, V> predicate, K _key,
                                       bool includeValue)
        {
            var keyData       = ToData(_key);
            var predicateData = ToData(predicate);
            var flags         = GetListenerFlags(listener);
            var request       = MapAddEntryListenerToKeyWithPredicateCodec.EncodeRequest(GetName(), keyData, predicateData,
                                                                                         includeValue, flags, false);
            DistributedEventHandler handler =
                eventData => MapAddEntryListenerToKeyWithPredicateCodec.AbstractEventHandler.Handle(eventData,
                                                                                                    (key, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener);
            });

            return(Listen(request, message => MapAddEntryListenerCodec.DecodeResponse(message).response, keyData,
                          handler));
        }
        public string AddEntryListener(IEntryListener <TKey, TValue> listener, IPredicate predicate,
                                       TKey key,
                                       bool includeValue)
        {
            var keyData       = ToData(key);
            var predicateData = ToData(predicate);
            var flags         = GetListenerFlags(listener);
            var request       = MapAddEntryListenerToKeyWithPredicateCodec.EncodeRequest(GetName(), keyData, predicateData,
                                                                                         includeValue, flags, IsSmart());
            DistributedEventHandler handler =
                eventData => MapAddEntryListenerToKeyWithPredicateCodec.AbstractEventHandler.Handle(eventData,
                                                                                                    (k, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(k, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener);
            });

            return(RegisterListener(request, message => MapAddEntryListenerCodec.DecodeResponse(message).response,
                                    id => MapRemoveEntryListenerCodec.EncodeRequest(GetName(), id), handler));
        }
Esempio n. 6
0
        public string AddEntryListener(MapListener listener, IPredicate predicate, TKey key, bool includeValue)
        {
            var keyData         = ToData(key);
            var predicateData   = ToData(predicate);
            var listenerAdapter =
                EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, GetContext().GetSerializationService());

            var listenerFlags = (int)listenerAdapter.ListenerFlags;
            var request       = MapAddEntryListenerToKeyWithPredicateCodec.EncodeRequest(GetName(), keyData, predicateData,
                                                                                         includeValue, listenerFlags, IsSmart());
            DistributedEventHandler handler = eventData =>
                                              MapAddEntryListenerToKeyWithPredicateCodec.EventHandler.HandleEvent(eventData,
                                                                                                                  (k, value, oldValue, mergingValue, type, uuid, entries) =>
            {
                OnEntryEvent(k, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter);
            });

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