From c54d35f7f6c4f4e3a3448ed97a825f0d6cac9cb8 Mon Sep 17 00:00:00 2001 From: spx Date: Sun, 3 Jul 2016 03:30:36 +0900 Subject: [PATCH] =?utf8?q?UserStreams=E3=81=AE=E6=8E=A5=E7=B6=9A=E3=82=92G?= =?utf8?q?etStreamingStreamAsync=E3=81=B8=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- OpenTween/Api/TwitterApi.cs | 2 +- OpenTween/Connection/IApiConnection.cs | 2 ++ OpenTween/Connection/TwitterApiConnection.cs | 22 ++++++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/OpenTween/Api/TwitterApi.cs b/OpenTween/Api/TwitterApi.cs index 088a2fd9..8d67f7e3 100644 --- a/OpenTween/Api/TwitterApi.cs +++ b/OpenTween/Api/TwitterApi.cs @@ -670,7 +670,7 @@ namespace OpenTween.Api if (!string.IsNullOrEmpty(track)) param["track"] = track; - return this.apiConnection.GetStreamAsync(endpoint, param); + return this.apiConnection.GetStreamingStreamAsync(endpoint, param); } public OAuthEchoHandler CreateOAuthEchoHandler(Uri authServiceProvider, Uri realm = null) diff --git a/OpenTween/Connection/IApiConnection.cs b/OpenTween/Connection/IApiConnection.cs index 2fca29ce..49064a30 100644 --- a/OpenTween/Connection/IApiConnection.cs +++ b/OpenTween/Connection/IApiConnection.cs @@ -34,6 +34,8 @@ namespace OpenTween.Connection Task GetStreamAsync(Uri uri, IDictionary param); + Task GetStreamingStreamAsync(Uri uri, IDictionary param); + Task> PostLazyAsync(Uri uri, IDictionary param); Task> PostLazyAsync(Uri uri, IDictionary param, IDictionary media); diff --git a/OpenTween/Connection/TwitterApiConnection.cs b/OpenTween/Connection/TwitterApiConnection.cs index fa9f87f2..4185ac80 100644 --- a/OpenTween/Connection/TwitterApiConnection.cs +++ b/OpenTween/Connection/TwitterApiConnection.cs @@ -137,6 +137,28 @@ namespace OpenTween.Connection } } + public async Task GetStreamingStreamAsync(Uri uri, IDictionary param) + { + var requestUri = new Uri(RestApiBase, uri); + + if (param != null) + requestUri = new Uri(requestUri, "?" + MyCommon.BuildQueryString(param)); + + try + { + return await this.httpStreaming.GetStreamAsync(requestUri) + .ConfigureAwait(false); + } + catch (HttpRequestException ex) + { + throw TwitterApiException.CreateFromException(ex); + } + catch (OperationCanceledException ex) + { + throw TwitterApiException.CreateFromException(ex); + } + } + public async Task> PostLazyAsync(Uri uri, IDictionary param) { var requestUri = new Uri(RestApiBase, uri); -- 2.11.0