1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-09 08:56:13 +00:00
2018-12-03 14:56:24 +01:00

76 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Security.Authentication;
using System.Text;
using System.Threading.Tasks;
using CryptoExchange.Net.Interfaces;
using WebSocket4Net;
namespace CryptoExchange.Net.UnitTests.TestImplementations
{
public class TestSocket: IWebsocket
{
public bool CanConnect { get; set; }
public bool Connected { get; set; }
public event Action OnClose;
public event Action<string> OnMessage;
public event Action<Exception> OnError;
public event Action OnOpen;
public int Id { get; }
public bool ShouldReconnect { get; set; }
public Func<byte[], string> DataInterpreter { get; set; }
public DateTime? DisconnectTime { get; set; }
public string Url { get; }
public WebSocketState SocketState { get; }
public bool IsClosed => !Connected;
public bool IsOpen => Connected;
public bool PingConnection { get; set; }
public TimeSpan PingInterval { get; set; }
public SslProtocols SSLProtocols { get; set; }
public Task<bool> Connect()
{
Connected = CanConnect;
return Task.FromResult(CanConnect);
}
public void Send(string data)
{
if(!Connected)
throw new Exception("Socket not connected");
}
public Task Close()
{
Connected = false;
return Task.FromResult(0);
}
public void SetProxy(string host, int port)
{
throw new NotImplementedException();
}
public void Dispose()
{
}
public void InvokeClose()
{
Connected = false;
OnClose?.Invoke();
}
public void InvokeOpen()
{
OnOpen?.Invoke();
}
public void InvokeMessage(string data)
{
OnMessage?.Invoke(data);
}
}
}