mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-07 16:06:15 +00:00
Updated test websocket
This commit is contained in:
parent
e86623a0b7
commit
28c42e3e5e
@ -7,7 +7,7 @@
|
||||
<PropertyGroup>
|
||||
<PackageId>CryptoExchange.Net</PackageId>
|
||||
<Authors>JKorf</Authors>
|
||||
<PackageVersion>0.0.29</PackageVersion>
|
||||
<PackageVersion>0.0.30</PackageVersion>
|
||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||
<PackageProjectUrl>https://github.com/JKorf/CryptoExchange.Net</PackageProjectUrl>
|
||||
<PackageLicenseUrl>https://github.com/JKorf/CryptoExchange.Net/blob/master/LICENSE</PackageLicenseUrl>
|
||||
|
@ -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<string> MessagesSend = new List<string>();
|
||||
|
||||
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<bool> 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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user