public static IObservable<StreamingMessage> StartObservableStream(this StreamingApi e, StreamingType type, StreamingParameters parameters = null) { if(parameters == null) parameters = new StreamingParameters(); return AccessStreamingApiAsObservableImpl(e, type, parameters.Parameters); }
/// <summary> /// Starts the Twitter stream. /// </summary> /// <param name="type">Type of streaming.</param> /// <param name="parameters">The parameters of streaming.</param> /// <returns>The stream messages.</returns> public IEnumerable <StreamingMessage> StartStream(StreamingType type, StreamingParameters parameters = null) { if (parameters == null) { parameters = new StreamingParameters(); } var url = type == StreamingType.User ? "https://userstream.twitter.com/1.1/user.json" : type == StreamingType.Site ? " https://sitestream.twitter.com/1.1/site.json " : type == StreamingType.Filter ? "https://stream.twitter.com/1.1/statuses/filter.json" : type == StreamingType.Sample ? "https://stream.twitter.com/1.1/statuses/sample.json" : type == StreamingType.Firehose ? "https://stream.twitter.com/1.1/statuses/firehose.json" : ""; var str = this.Connect(parameters, type == StreamingType.Filter ? MethodType.Post : MethodType.Get, url) .Where(x => !string.IsNullOrEmpty(x)); foreach (var s in str) { StreamingMessage m; #if !DEBUG try { #endif m = StreamingMessage.Parse(s); #if !DEBUG } catch { m = RawJsonMessage.Create(s); } #endif yield return(m); } }
/// <summary> /// Create an observable object. /// </summary> static IObservable <StreamingMessage> ReactiveBase(this StreamingApi e, StreamingType type, StreamingParameters parameters = null) { return(Observable.Create <StreamingMessage>((observer, cancel) => Task.Factory.StartNew(() => { var url = type == StreamingType.User ? "https://userstream.twitter.com/1.1/user.json" : type == StreamingType.Site ? " https://sitestream.twitter.com/1.1/site.json " : type == StreamingType.Filter ? "https://stream.twitter.com/1.1/statuses/filter.json" : type == StreamingType.Sample ? "https://stream.twitter.com/1.1/statuses/sample.json" : type == StreamingType.Firehose ? "https://stream.twitter.com/1.1/statuses/firehose.json" : ""; cancel.ThrowIfCancellationRequested(); using (var reader = Connect(e.IncludedTokens, parameters, type == StreamingType.Filter ? MethodType.Post : MethodType.Get, url)) { cancel.ThrowIfCancellationRequested(); cancel.Register(() => reader.Close()); foreach (var s in reader.EnumerateLines().Where(x => !string.IsNullOrEmpty(x))) { observer.OnNext(RawJsonMessage.Create(e.IncludedTokens, s)); observer.OnNext(StreamingMessage.Parse(e.IncludedTokens, s)); } } }, cancel, TaskCreationOptions.LongRunning, TaskScheduler.Default))); }
/// <summary> /// Create an observable object. /// </summary> static IObservable<StreamingMessage> ReactiveBase(this StreamingApi e, StreamingType type, StreamingParameters parameters = null) { return Observable.Create<StreamingMessage>((observer, cancel) => Task.Factory.StartNew(() => { var url = type == StreamingType.User ? "https://userstream.twitter.com/1.1/user.json" : type == StreamingType.Site ? " https://sitestream.twitter.com/1.1/site.json " : type == StreamingType.Filter ? "https://stream.twitter.com/1.1/statuses/filter.json" : type == StreamingType.Sample ? "https://stream.twitter.com/1.1/statuses/sample.json" : type == StreamingType.Firehose ? "https://stream.twitter.com/1.1/statuses/firehose.json" : ""; cancel.ThrowIfCancellationRequested(); using(var reader = Connect(e.IncludedTokens, parameters, type == StreamingType.Filter ? MethodType.Post : MethodType.Get, url)) { cancel.ThrowIfCancellationRequested(); cancel.Register(() => reader.Close()); foreach(var s in reader.EnumerateLines().Where(x => !string.IsNullOrEmpty(x))) { observer.OnNext(RawJsonMessage.Create(e.IncludedTokens, s)); observer.OnNext(StreamingMessage.Parse(e.IncludedTokens, s)); } } }, cancel, TaskCreationOptions.LongRunning, TaskScheduler.Default)); }
public Task <IEnumerable <StreamingMessage> > StartStreamAsync(StreamingType type, StreamingParameters parameters = null, CancellationToken cancellationToken = default(CancellationToken)) { if (parameters == null) { parameters = new StreamingParameters(); } return(this.Tokens.SendStreamingRequestAsync(this.GetMethodType(type), this.GetUrl(type), parameters.Parameters, cancellationToken) .ContinueWith(t => { if (t.IsFaulted) { t.Exception.InnerException.Rethrow(); } return t.Result.GetResponseStreamAsync(); }, cancellationToken) .Unwrap() .ContinueWith(t => { if (t.IsFaulted) { t.Exception.InnerException.Rethrow(); } return EnumerateMessages(t.Result); }, cancellationToken)); }
/// <summary> /// 이미지가 표시될 크기를 얻습니다. /// PictureBox의 사이즈 모드에 따라 이미지의 크기가 변경되므로 이 메소드를 이용해 정확한 크기를 얻어야합니다. /// </summary> /// <param name="streamingType">스트리밍 타입</param> /// <param name="frame">표시될 이미지</param> /// <returns>표시될 이미지의 크기</returns> public OpenCvSharp.Size GetDisplaySize(StreamingType streamingType, Mat frame) { if (this.Visualizer.StreamingType == streamingType) { this._cachedDisplaySize = frame.Size(); } if (this.defaultView.streamingFrameBox.SizeMode == PictureBoxSizeMode.CenterImage) { if (this.Blender.Enabled) { this._cachedDisplaySize = this.Blender.Size; } return(this._cachedDisplaySize); } else if (this.defaultView.streamingFrameBox.SizeMode == PictureBoxSizeMode.StretchImage) { return(new OpenCvSharp.Size(this.defaultView.streamingFrameBox.Width, this.defaultView.streamingFrameBox.Height)); } else { var aspect = this._cachedDisplaySize.Width / (float)this._cachedDisplaySize.Height; if (this._cachedDisplaySize.Width > this._cachedDisplaySize.Height) { return(new OpenCvSharp.Size(this.defaultView.streamingFrameBox.Width, this.defaultView.streamingFrameBox.Height / aspect)); } else { return(new OpenCvSharp.Size(this.defaultView.streamingFrameBox.Width * aspect, this.defaultView.streamingFrameBox.Height)); } } }
public StreamingObservable(Tokens tokens, StreamingType type, IDictionary <string, object> parameters = null) { _tokens = tokens; _type = type; _parameters = parameters; }
private TimelineStreaming GetStreaming(StreamingType streamingType, string?param) { #if NETSTANDARD2_0 return(new TimelineWebSocketStreaming(streamingType, param, Instance, instanceGetter.Value, AuthToken?.AccessToken, client)); #else return(new TimelineHttpStreaming(streamingType, param, Instance, AuthToken?.AccessToken, client)); #endif }
public OYOVisualizer() { this.StreamingType = StreamingType.Infrared; this.Palette = "Grayscale"; this.VisualCropRect = new Rect(new Point(0, 0), new Size(640, 480)); this.InfraredCropRect = new Rect(new Point(0, 0), new Size(640, 480)); }
/// <summary> /// Starting streaming and get streaming controller. /// </summary> /// <param name="provider">using credential</param> /// <param name="type">type of streaming</param> /// <param name="delimitered">delimiter length</param> /// <param name="count">backlog count</param> /// <param name="follow">following user's id</param> /// <param name="track">tracking keywords</param> /// <param name="locations">location area of tweet</param> /// <param name="repliesAll">use @replies=all option</param> public static StreamingController BeginStreaming (CredentialProvider provider, StreamingType type, int? delimitered = null, int? count = null, string follow = null, string track = null, string locations = null, bool repliesAll = false) { CredentialProvider.RequestMethod reqmethod = CredentialProvider.RequestMethod.GET; // argument check switch (type) { case StreamingType.firehose: if (!String.IsNullOrWhiteSpace(follow) || !String.IsNullOrWhiteSpace(track) || !String.IsNullOrWhiteSpace(locations)) throw new ArgumentException("Invalid argument is setted."); break; case StreamingType.gardenhose: if (count != null && !String.IsNullOrWhiteSpace(follow) || !String.IsNullOrWhiteSpace(track) || !String.IsNullOrWhiteSpace(locations)) throw new ArgumentException("Invalid argument is setted."); break; case StreamingType.sample: if (count != null && !String.IsNullOrWhiteSpace(follow) || !String.IsNullOrWhiteSpace(track) || !String.IsNullOrWhiteSpace(locations)) throw new ArgumentException("Invalid argument is setted."); break; case StreamingType.birddog: if (!String.IsNullOrWhiteSpace(track) || !String.IsNullOrWhiteSpace(locations)) throw new ArgumentException("Invalid argument is setted."); reqmethod = CredentialProvider.RequestMethod.POST; break; case StreamingType.shadow: if (!String.IsNullOrWhiteSpace(track) || !String.IsNullOrWhiteSpace(locations)) throw new ArgumentException("Invalid argument is setted."); reqmethod = CredentialProvider.RequestMethod.POST; break; case StreamingType.filter: if (String.IsNullOrWhiteSpace(track) && String.IsNullOrWhiteSpace(follow)) throw new ArgumentException("You must set follow or track argument."); reqmethod = CredentialProvider.RequestMethod.POST; break; } List<KeyValuePair<string, string>> args = new List<KeyValuePair<string, string>>(); if (delimitered != null) args.Add(new KeyValuePair<string, string>("delimitered", delimitered.Value.ToString())); if (count != null) args.Add(new KeyValuePair<string, string>("count", count.Value.ToString())); if (!String.IsNullOrWhiteSpace(follow)) args.Add(new KeyValuePair<string, string>("follow", Tweak.CredentialProviders.OAuth.UrlEncode(follow, Encoding.UTF8, true))); if (!String.IsNullOrWhiteSpace(track)) args.Add(new KeyValuePair<string, string>("track", Tweak.CredentialProviders.OAuth.UrlEncode(track, Encoding.UTF8, true))); if (!String.IsNullOrWhiteSpace(locations)) args.Add(new KeyValuePair<string, string>("locations", Tweak.CredentialProviders.OAuth.UrlEncode(locations, Encoding.UTF8, true))); if (repliesAll) args.Add(new KeyValuePair<string, string>("replies", "all")); var strm = provider.RequestStreamingAPI(GetStreamingUri(type), reqmethod, args); if (strm != null) return new StreamingController(strm); else return null; }
public INetworkingEntity Create(ulong id, IEntityStreamer entityStreamer, Entity.Entity streamedEntity, StreamingType streamingType = StreamingType.Default) { streamedEntity.Id = id; var entity = factory.Create(entityStreamer, streamedEntity, streamingType); Add(entity); return(entity); }
public IEnumerable <StreamingMessage> StartStream(StreamingType type, StreamingParameters parameters = null) { if (parameters == null) { parameters = new StreamingParameters(); } return(this.AccessStreamingApiImpl(type, parameters.Parameters)); }
public override int GetHashCode() { int hash = 23; unchecked { hash = hash * 17 + UserId.GetHashCode(); hash = hash * 17 + StreamingType.GetHashCode(); } return(hash); }
private CredentialProvider.RequestMethod GetStreamingMethod(StreamingType type) { switch (type) { case StreamingType.filter: return(CredentialProvider.RequestMethod.POST); default: return(CredentialProvider.RequestMethod.GET); } }
public Mat Crop(Mat source, StreamingType type) { source = source.Resize(new OpenCvSharp.Size(640, 480)); if (type == StreamingType.Visual) { return(source.Clone(this.VisualCropRect).Resize(new Size(640, 480))); } else { return(source.Clone(this.InfraredCropRect).Resize(new Size(640, 480))); } }
public Task <IEnumerable <StreamingMessage> > StartStreamAsync(StreamingType type, StreamingParameters parameters = null, CancellationToken cancellationToken = default(CancellationToken)) { if (parameters == null) { parameters = new StreamingParameters(); } return(this.Tokens.SendStreamingRequestAsync(GetMethodType(type), this.GetUrl(type), parameters.Parameters, cancellationToken) .Done(res => res.GetResponseStreamAsync(), cancellationToken) .Unwrap() .Done(stream => EnumerateMessages(stream), cancellationToken)); }
/// <summary> /// Starts the stream. /// </summary> /// <returns>The observable object.</returns> /// <param name="e">Tokens.</param> /// <param name="type">Type of streaming API.</param> /// <param name="parameters">Parameters.</param> public static IObservable<StreamingMessage> StartObservableStream(this StreamingApi e, StreamingType type, StreamingParameters parameters = null) { if(parameters == null) parameters = new StreamingParameters(); return Observable.Create<StreamingMessage>((observer, cancel) => { var url = type == StreamingType.User ? "https://userstream.twitter.com/1.1/user.json" : type == StreamingType.Site ? " https://sitestream.twitter.com/1.1/site.json " : type == StreamingType.Filter ? "https://stream.twitter.com/1.1/statuses/filter.json" : type == StreamingType.Sample ? "https://stream.twitter.com/1.1/statuses/sample.json" : type == StreamingType.Firehose ? "https://stream.twitter.com/1.1/statuses/firehose.json" : ""; return e.IncludedTokens.SendStreamingRequestAsync(type == StreamingType.Filter ? MethodType.Post : MethodType.Get, url, parameters.Parameters, cancel) .ContinueWith(task => { if(task.IsFaulted) throw task.Exception.InnerException; return task.Result.GetResponseStreamAsync(); }, cancel) .Unwrap() .ContinueWith(task => { if(task.IsFaulted) throw task.Exception.InnerException; using(var reader = new StreamReader(task.Result)) using(var reg = cancel.Register(() => reader.Dispose())) { foreach(var s in reader.EnumerateLines().Where(x => !string.IsNullOrEmpty(x))) { observer.OnNext(RawJsonMessage.Create(e.IncludedTokens, s)); #if !DEBUG try { #endif observer.OnNext(StreamingMessage.Parse(e.IncludedTokens, s)); #if !DEBUG } catch { } #endif } } }, cancel, TaskContinuationOptions.LongRunning, TaskScheduler.Default) .ContinueWith(task => { if(task.IsFaulted) throw task.Exception.InnerException; }, cancel); }); }
private StreamingDescription( StreamingType type, int timeout, int?count = null, int?delimited = null, string follow = null, string track = null, string locations = null, bool?repliesAll = null, string with = null) { this.Type = type; this.Timeout = timeout; this.Delimited = delimited; this.Count = count; this.Follow = follow; this.Track = track; this.Locations = locations; this.RepliesAll = repliesAll; this.With = with; }
private string GetStreamingUri(StreamingType type) { switch (type) { case StreamingType.firehose: case StreamingType.sample: case StreamingType.links: case StreamingType.retweet: case StreamingType.filter: return(String.Format(SapiV1, type.ToString())); case StreamingType.user: return("https://userstream.twitter.com/1.1/user.json"); default: throw new ArgumentOutOfRangeException("Invalid streaming value"); } }
private static IObservable<StreamingMessage> AccessStreamingApiAsObservableImpl(StreamingApi e, StreamingType type, IEnumerable<KeyValuePair<string, object>> parameters) { return Observable.Create<StreamingMessage>((observer, cancel) => { return e.IncludedTokens.SendStreamingRequestAsync(GetMethodType(type), e.GetUrl(type), parameters, cancel) .ContinueWith(task => { if(task.IsFaulted) task.Exception.InnerException.Rethrow(); return task.Result.GetResponseStreamAsync(); }, cancel) .Unwrap() .ContinueWith(task => { if(task.IsFaulted) task.Exception.InnerException.Rethrow(); try { using (var reader = new StreamReader(task.Result)) using (cancel.Register(() => reader.Dispose())) { foreach (var s in reader.EnumerateLines().Where(x => !string.IsNullOrEmpty(x))) { try { observer.OnNext(StreamingMessage.Parse(s)); } catch (ParsingException ex) { observer.OnNext(RawJsonMessage.Create(s, ex)); } } } } finally { cancel.ThrowIfCancellationRequested(); } }, cancel, TaskContinuationOptions.LongRunning, TaskScheduler.Default); }); }
// // Receive // 서버로부터 데이터를 얻어옵니다. // // Parameters // streamingType 서버로부터 얻은 데이터가 어떤 데이터인지가 저장됩니다. // Infrared라면 방사값을, Visual이라면 실화상 이미지를 얻습니다. // // Return // 해당 데이터를 바이트배열 형식으로 리턴합니다. // private byte[] Receive(ref StreamingType streamingType, ref int width, ref int height) { var header = this.Receive(sizeof(int) * 4); if (header == null) { return(null); } using (var reader = new BinaryReader(new MemoryStream(header))) { var type = reader.ReadInt32(); streamingType = (type == 0 ? StreamingType.Infrared : StreamingType.Visual); width = reader.ReadInt32(); height = reader.ReadInt32(); var size = reader.ReadInt32(); return(this.Receive(size)); } }
/// <summary> /// UserStream に接続します。 /// </summary> /// <param name="token">Tokens</param> /// <param name="action"></param> public void StartStreaming(Tokens token, Action <Status> action, StreamingType type = StreamingType.User) { if (IsRunning) { return; } IsRunning = true; var streamRx = token.Streaming.StartObservableStream(type).Publish(); Action <StatusMessage> getStatus = (message) => { var status = (message as StatusMessage).Status; status.Source = Regex.Replace(status.Source, @"^(<.*>)(.*)(<.*>)$", "$2"); action(status); }; streamRx.OfType <StatusMessage>().Subscribe(getStatus); streaming = streamRx.Connect(); }
internal string GetUrl(StreamingType type) { var options = Tokens.ConnectionOptions ?? new ConnectionOptions(); string baseUrl; string apiName; switch (type) { case StreamingType.User: baseUrl = options.UserStreamUrl; apiName = "user.json"; break; case StreamingType.Site: baseUrl = options.SiteStreamUrl; apiName = "site.json"; break; case StreamingType.Filter: baseUrl = options.StreamUrl; apiName = "statuses/filter.json"; break; case StreamingType.Sample: baseUrl = options.StreamUrl; apiName = "statuses/sample.json"; break; case StreamingType.Firehose: baseUrl = options.StreamUrl; apiName = "statuses/firehose.json"; break; default: throw new ArgumentException("Invalid StreamingType."); } return(InternalUtils.GetUrl(options, baseUrl, true, apiName)); }
// // Update // 서버로부터 데이터를 얻고 해당 데이터를 가공합니다. // 이 함수가 호출되므로써 방사값과 관련된 정보(온도정보와 적외선 이미지)가 갱신됩니다. // // Parameters // streamingType 서버로부터 얻은 데이터가 어떤 데이터인지가 저장됩니다. // Infrared라면 방사값을, Visual이라면 실화상 이미지를 얻습니다. // private void Update(ref StreamingType streamingType) { var width = 0; var height = 0; var buffer = this.Receive(ref streamingType, ref width, ref height); if (buffer == null) { throw new SocketException(10024); } if (streamingType == StreamingType.Infrared) { this._radioactiveTable = new ushort[height, width]; this._temperatureTable = new float[height, width]; var reader = new BinaryReader(new MemoryStream(buffer)); for (var row = 0; row < height; row++) { for (var col = 0; col < width; col++) { this._radioactiveTable[row, col] = reader.ReadUInt16(); this._temperatureTable[row, col] = Radioactive2Temperature(this._radioactiveTable[row, col]); } } } else if (streamingType == StreamingType.Visual) { this._visual = Cv2.ImDecode(buffer, ImreadModes.AnyColor); this._visual = this._visual.Clone(this._vcrop); } else { } }
private static IObservable<StreamingMessage> AccessStreamingApiAsObservable(StreamingApi e, StreamingType type, object parameters) { return AccessStreamingApiAsObservableImpl(e, type, InternalUtils.ResolveObject(parameters)); }
private static IObservable<StreamingMessage> AccessStreamingApiAsObservable(StreamingApi e, StreamingType type, IDictionary<string, object> parameters) { return AccessStreamingApiAsObservableImpl(e, type, parameters); }
private static IObservable<StreamingMessage> AccessStreamingApiAsObservable(StreamingApi e, StreamingType type, Expression<Func<string, object>>[] parameters) { return AccessStreamingApiAsObservableImpl(e, type, InternalUtils.ExpressionsToDictionary(parameters)); }
private IObservable <StreamingMessage> AccessStreamingApiAsObservable(StreamingType type, object parameters) { return(AccessStreamingApiAsObservableImpl(type, InternalUtils.ResolveObject(parameters))); }
public ParserKey(ulong id, StreamingType type) { UserId = id; StreamingType = type; }
public TimelineWebSocketStreaming(StreamingType type, string?param, string instance, Task <Instance> instanceGetter, string?accessToken) : this(type, param, instance, instanceGetter, accessToken, DefaultHttpClient.Instance) { }
public TimelineHttpStreaming(StreamingType type, string param, string instance, string accessToken, HttpClient client) : base(type, param, accessToken) { this.client = client; this.instance = instance; }
public TimelineHttpStreaming(StreamingType type, string param, string instance, string accessToken) : this(type, param, instance, accessToken, DefaultHttpClient.Instance) { }
private StreamingDescription( StreamingType type, int timeout, int? count = null, int? delimited = null, string follow = null, string track = null, string locations = null, bool? repliesAll = null, string with = null) { this.Type = type; this.Timeout = timeout; this.Delimited = delimited; this.Count = count; this.Follow = follow; this.Track = track; this.Locations = locations; this.RepliesAll = repliesAll; this.With = with; }
private CredentialProvider.RequestMethod GetStreamingMethod(StreamingType type) { switch (type) { case StreamingType.filter: return CredentialProvider.RequestMethod.POST; default: return CredentialProvider.RequestMethod.GET; } }
private string GetStreamingUri(StreamingType type) { switch (type) { case StreamingType.firehose: case StreamingType.sample: case StreamingType.links: case StreamingType.retweet: case StreamingType.filter: return String.Format(SapiV1, type.ToString()); case StreamingType.user: return "https://userstream.twitter.com/1.1/user.json"; default: throw new ArgumentOutOfRangeException("Invalid streaming value"); } }
public async void Start(IObserver <StreamingMessage> observer, StreamingApi client, StreamingType type, KeyValuePair <string, object>[] parameters) { var token = this.cancel.Token; try { // Make sure that all the operations are run in background var firstTask = Task.Run(() => client.IncludedTokens.SendStreamingRequestAsync(GetMethodType(type), client.GetUrl(type), parameters, token), token); using (var res = await firstTask.ConfigureAwait(false)) using (var reader = new StreamReader(await res.GetResponseStreamAsync().ConfigureAwait(false))) { while (!reader.EndOfStream) { if (token.IsCancellationRequested) { return; } var line = await reader.ReadLineAsync().ConfigureAwait(false); if (!string.IsNullOrEmpty(line)) { StreamingMessage message; try { message = StreamingMessage.Parse(line); } catch (ParsingException ex) { message = RawJsonMessage.Create(line, ex); } if (token.IsCancellationRequested) { return; } observer.OnNext(message); } } } observer.OnCompleted(); } catch (Exception ex) { if (!token.IsCancellationRequested) { observer.OnError(ex); } } }
public TimelineWebSocketStreaming(StreamingType type, string?param, string instance, Task <Instance> instanceGetter, string?accessToken, HttpClient client) : base(type, param, instance, accessToken, client) { this.instanceGetter = instanceGetter; }
internal static MethodType GetMethodType(StreamingType type) { return(type == StreamingType.Filter ? MethodType.Post : MethodType.Get); }
public StreamingObservable(StreamingApi client, StreamingType type, IEnumerable <KeyValuePair <string, object> > parameters) { this.client = client; this.type = type; this.parameters = parameters.ToArray(); }
protected TimelineStreaming(StreamingType type, string?param, string?accessToken) { this.streamingType = type; this.param = param; this.accessToken = accessToken; }
public void Start(IObserver <StreamingMessage> observer, StreamingApi client, StreamingType type, KeyValuePair <string, object>[] parameters) { var token = this.cancel.Token; client.IncludedTokens.SendStreamingRequestAsync(GetMethodType(type), client.GetUrl(type), parameters, token) .Done(res => res.GetResponseStreamAsync(), token) .Unwrap() .Done(stream => { using (var reader = new StreamReader(stream)) using (token.Register(reader.Dispose)) { foreach (var s in reader.EnumerateLines().Where(x => !string.IsNullOrEmpty(x))) { try { observer.OnNext(StreamingMessage.Parse(s)); } catch (ParsingException ex) { observer.OnNext(RawJsonMessage.Create(s, ex)); } } } observer.OnCompleted(); }, token, true) .ContinueWith(t => { if (!token.IsCancellationRequested) { if (t.Exception != null) { observer.OnError(t.Exception.InnerExceptions.Count == 1 ? t.Exception.InnerException : t.Exception); } else if (t.IsCanceled) { observer.OnError(new TaskCanceledException(t)); } } }); }
/// <summary> /// Starts the stream. /// </summary> /// <returns>The observable object.</returns> /// <param name="e">Tokens.</param> /// <param name="type">Type of streaming API.</param> /// <param name="parameters">Parameters.</param> public static IObservable<StreamingMessage> StartObservableStream(this StreamingApi e, StreamingType type, StreamingParameters parameters = null) { if(parameters == null) parameters = new StreamingParameters(); return ReactiveBase(e, type, parameters); }