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, IPredicate <K, V> predicate, bool includeValue) { var predicateData = ToData(predicate); var flags = GetListenerFlags(listener); var request = MapAddEntryListenerWithPredicateCodec.EncodeRequest(GetName(), predicateData, includeValue, flags, false); DistributedEventHandler handler = eventData => MapAddEntryListenerWithPredicateCodec.AbstractEventHandler.Handle(eventData, (key, value, oldValue, mergingValue, type, uuid, entries) => { OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, includeValue, listener); }); return(Listen(request, message => MapAddEntryListenerWithPredicateCodec.DecodeResponse(message).response, null, handler)); }
public Guid AddEntryListener(MapListener listener, IPredicate predicate, bool includeValue) { var predicateData = ToData(predicate); var listenerAdapter = EntryListenerAdapter <TKey, TValue> .CreateAdapter(listener, Client.SerializationService); var listenerFlags = (int)listenerAdapter.ListenerFlags; var request = MapAddEntryListenerWithPredicateCodec.EncodeRequest(Name, predicateData, includeValue, listenerFlags, IsSmart()); DistributedEventHandler handler = eventData => MapAddEntryListenerWithPredicateCodec.EventHandler.HandleEvent(eventData, (key, value, oldValue, mergingValue, type, uuid, entries) => { OnEntryEvent(key, value, oldValue, mergingValue, type, uuid, entries, listenerAdapter); }); return(RegisterListener(request, message => MapAddEntryListenerWithPredicateCodec.DecodeResponse(message).Response, id => MapRemoveEntryListenerCodec.EncodeRequest(Name, id), handler)); }