コード例 #1
0
        //internal EventStreamResponse(
        //    HttpResponseMessage httpResponse,
        //    ValueAddedEventHandler added = null,
        //    ValueChangedEventHandler changed = null,
        //    ValueRemovedEventHandler removed = 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;
        //    }

        //    _pollingTask = ReadLoop(httpResponse, _cancel.Token);
        //}

        internal EventStreamResponse(
            IRequestManager requestManager,
            string listenPath,
            ValueAddedEventHandler added = null,
            ValueChangedEventHandler changed = null,
            ValueRemovedEventHandler removed = null)
        {
            this._requestManager = requestManager;
            this._listenPath = listenPath;

            _cancel = new CancellationTokenSource();

            _cache = new TemporaryCache();

            if (added != null)
            {
                _cache.Added += added;
            }
            if (changed != null)
            {
                _cache.Changed += changed;
            }
            if (removed != null)
            {
                _cache.Removed += removed;
            }
        }
コード例 #2
0
        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);
        }