internal EventStreamResponse(HttpResponseMessage httpResponse,
                                     ValueAddedEventHandler added     = null,
                                     ValueChangedEventHandler changed = null,
                                     ValueRemovedEventHandler removed = null,
                                     object context = null)
        {
            _cancel = new CancellationTokenSource();

            _cache = new TemporaryCache();

            if (added != null)
            {
                _cache.Added += added;
            }
            if (changed != null)
            {
                _cache.Changed += changed;
            }
            if (removed != null)
            {
                _cache.Removed += removed;
            }
            if (context != null)
            {
                _cache.Context = context;
            }

            _pollingTask = ReadLoop(httpResponse, _cancel.Token);
        }
Example #2
0
        internal EventStreamResponse(ISerializer serializer, HttpResponseMessage httpResponse,
                                     ObjectRootPatchReceivedEventHandler <T> rootPatchReceived           = null,
                                     ObjectPropertyPatchReceivedEventHandler <T> propertyPatchReceived   = null,
                                     EventStreamingResponseEventHandler <T> eventStreamingResponse       = null,
                                     EventStreamingResponseRawEventHandler <T> eventStreamingResponseRaw = null,
                                     EventStreamingEventHandler <T> eventStreaming = null,
                                     Action <Exception> exceptionHandler           = null)
        {
            _serializer = serializer;
            _fireCache  = new FireCache();
            _cache      = new TemporaryCache();

            this.CancellationToken = new CancellationTokenSource();
            this.ExceptionHandler  = exceptionHandler;

            if (rootPatchReceived != null)
            {
                this.OnObjectRootPatchReceived += rootPatchReceived;
            }
            if (propertyPatchReceived != null)
            {
                this.OnObjectPropertyPatchReceived += propertyPatchReceived;
                _jsonPatchManager = new JsonPatcher(_serializer);
            }
            if (eventStreamingResponse != null)
            {
                this.OnEventStreamingResponse += eventStreamingResponse;
            }
            if (eventStreamingResponseRaw != null)
            {
                this.OnEventStreamingResponseRaw += eventStreamingResponseRaw;
            }
            if (eventStreaming != null)
            {
                this.OnEventStreaming += eventStreaming;
            }
            _pollingTask = ReadLoop(httpResponse, CancellationToken.Token);
        }
Example #3
0
 public TemporaryCacheAccount(TimeSpan timeAvailableCash)
 {
     PasswordReqCache = new TemporaryCache <Account>(timeAvailableCash);
     OtpReqCache      = new TemporaryCache <Account>(timeAvailableCash);
 }