1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-10 17:36:19 +00:00

Fixed nullpointer on socket

This commit is contained in:
JKorf 2018-11-27 13:40:28 +01:00
parent 86674c83f5
commit 9648606bdc
3 changed files with 3 additions and 5 deletions

View File

@ -22,8 +22,7 @@ namespace CryptoExchange.Net.Interfaces
bool IsOpen { get; }
bool PingConnection { get; set; }
TimeSpan PingInterval { get; set; }
void SetEnabledSslProtocols(SslProtocols protocols);
SslProtocols SSLProtocols { get; set; }
Task<bool> Connect();
void Send(string data);
Task Close();

View File

@ -22,8 +22,6 @@ namespace CryptoExchange.Net
/// </summary>
public virtual IWebsocketFactory SocketFactory { get; set; } = new WebsocketFactory();
private const SslProtocols protocols = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
protected List<SocketSubscription> sockets = new List<SocketSubscription>();
protected TimeSpan reconnectInterval;
@ -66,7 +64,6 @@ namespace CryptoExchange.Net
if (apiProxy != null)
socket.SetProxy(apiProxy.Host, apiProxy.Port);
socket.SetEnabledSslProtocols(protocols);
socket.DataInterpreter = dataInterpreter;
socket.OnClose += () =>
{

View File

@ -37,6 +37,7 @@ namespace CryptoExchange.Net.Sockets
public string Url { get; }
public bool IsClosed => socket.State == WebSocketState.Closed;
public bool IsOpen => socket.State == WebSocketState.Open;
public SslProtocols SSLProtocols { get; set; } = SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls;
public Func<byte[], string> DataInterpreter { get; set; }
public bool PingConnection
@ -161,6 +162,7 @@ namespace CryptoExchange.Net.Sockets
EnableAutoSendPing = true,
AutoSendPingInterval = 10
};
socket.Security.EnabledSslProtocols = SSLProtocols;
socket.Opened += (o, s) => Handle(openHandlers);
socket.Closed += (o, s) => Handle(closeHandlers);
socket.Error += (o, s) => Handle(errorHandlers, s.Exception);