using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Client.SSE { public class DisconnectedState : IConnectionState { private Uri mUrl; private IWebRequesterFactory mWebRequesterFactory; private Dictionary headers; public EventSourceState State { get { return EventSourceState.CLOSED; } } public DisconnectedState(Uri url, IWebRequesterFactory webRequesterFactory, Dictionary headers) { if (url == null) throw new ArgumentNullException("Url cant be null"); mUrl = url; mWebRequesterFactory = webRequesterFactory; this.headers = headers; } public Task Run(Action donothing, CancellationToken cancelToken, Dictionary headers) { if(cancelToken.IsCancellationRequested) return Task.Factory.StartNew(() => { return new DisconnectedState(mUrl, mWebRequesterFactory, headers); }); else return Task.Factory.StartNew(() => { return new ConnectingState(mUrl, mWebRequesterFactory, headers); }); } } }