1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-12 02:16:23 +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 IsOpen { get; }
bool PingConnection { get; set; } bool PingConnection { get; set; }
TimeSpan PingInterval { get; set; } TimeSpan PingInterval { get; set; }
SslProtocols SSLProtocols { get; set; }
void SetEnabledSslProtocols(SslProtocols protocols);
Task<bool> Connect(); Task<bool> Connect();
void Send(string data); void Send(string data);
Task Close(); Task Close();

View File

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

View File

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