From 28c42e3e5ec1bbe4bf74261e57727215c274757f Mon Sep 17 00:00:00 2001 From: JKorf Date: Mon, 2 Jul 2018 10:04:08 +0200 Subject: [PATCH] Updated test websocket --- CryptoExchange.Net/CryptoExchange.Net.csproj | 2 +- .../Implementation/TestWebsocket.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CryptoExchange.Net/CryptoExchange.Net.csproj b/CryptoExchange.Net/CryptoExchange.Net.csproj index a2d413a..2f2474e 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.csproj +++ b/CryptoExchange.Net/CryptoExchange.Net.csproj @@ -7,7 +7,7 @@ CryptoExchange.Net JKorf - 0.0.29 + 0.0.30 false https://github.com/JKorf/CryptoExchange.Net https://github.com/JKorf/CryptoExchange.Net/blob/master/LICENSE diff --git a/CryptoExchange.Net/Implementation/TestWebsocket.cs b/CryptoExchange.Net/Implementation/TestWebsocket.cs index debdde2..384b053 100644 --- a/CryptoExchange.Net/Implementation/TestWebsocket.cs +++ b/CryptoExchange.Net/Implementation/TestWebsocket.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Security.Authentication; using System.Threading; using System.Threading.Tasks; @@ -8,6 +9,8 @@ namespace CryptoExchange.Net.Implementation { public class TestWebsocket: IWebsocket { + public List MessagesSend = new List(); + public void Dispose() { } @@ -30,8 +33,16 @@ namespace CryptoExchange.Net.Implementation public bool PingConnection { get; set; } public TimeSpan PingInterval { get; set; } + public bool HasConnection = true; + public Task Connect() { + if (!HasConnection) + { + OnError(new Exception("No connection")); + return Task.FromResult(false); + } + IsClosed = false; IsOpen = true; OnOpen?.Invoke(); @@ -41,6 +52,14 @@ namespace CryptoExchange.Net.Implementation public void Send(string data) { + if (!HasConnection) + { + OnError(new Exception("No connection")); + Close(); + return; + } + + MessagesSend.Add(data); } public void EnqueueMessage(string data)