From 633c572a228ec9a62472cd86d12b24cd7b83c0d7 Mon Sep 17 00:00:00 2001 From: moozzyk Date: Thu, 9 Feb 2017 10:59:41 -0800 Subject: [PATCH] Fixing build --- .../Connection.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Microsoft.AspNetCore.Sockets.Client/Connection.cs b/src/Microsoft.AspNetCore.Sockets.Client/Connection.cs index 2fa57d2ac2..3312afc0e6 100644 --- a/src/Microsoft.AspNetCore.Sockets.Client/Connection.cs +++ b/src/Microsoft.AspNetCore.Sockets.Client/Connection.cs @@ -104,6 +104,7 @@ namespace Microsoft.AspNetCore.Sockets.Client { Output.TryComplete(); await _transport.StopAsync(); + await DrainMessages(); } public void Dispose() @@ -112,6 +113,17 @@ namespace Microsoft.AspNetCore.Sockets.Client _transport.Dispose(); } + private async Task DrainMessages() + { + while (await Input.WaitToReadAsync()) + { + if (Input.TryRead(out Message message)) + { + message.Dispose(); + } + } + } + public static Task ConnectAsync(Uri url, ITransport transport) => ConnectAsync(url, transport, null, null); public static Task ConnectAsync(Uri url, ITransport transport, ILoggerFactory loggerFactory) => ConnectAsync(url, transport, null, loggerFactory); public static Task ConnectAsync(Uri url, ITransport transport, HttpClient httpClient) => ConnectAsync(url, transport, httpClient, null);