mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-08 00:16:27 +00:00
Added handling for websocket options not being supported when running on WebAssembly
This commit is contained in:
parent
1e5f19271b
commit
98dad4a8ed
@ -9,6 +9,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -156,6 +157,8 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
cookieContainer.Add(new Cookie(cookie.Key, cookie.Value));
|
cookieContainer.Add(new Cookie(cookie.Key, cookie.Value));
|
||||||
|
|
||||||
var socket = new ClientWebSocket();
|
var socket = new ClientWebSocket();
|
||||||
|
try
|
||||||
|
{
|
||||||
socket.Options.Cookies = cookieContainer;
|
socket.Options.Cookies = cookieContainer;
|
||||||
foreach (var header in Parameters.Headers)
|
foreach (var header in Parameters.Headers)
|
||||||
socket.Options.SetRequestHeader(header.Key, header.Value);
|
socket.Options.SetRequestHeader(header.Key, header.Value);
|
||||||
@ -163,6 +166,13 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
socket.Options.SetBuffer(65536, 65536); // Setting it to anything bigger than 65536 throws an exception in .net framework
|
socket.Options.SetBuffer(65536, 65536); // Setting it to anything bigger than 65536 throws an exception in .net framework
|
||||||
if (Parameters.Proxy != null)
|
if (Parameters.Proxy != null)
|
||||||
SetProxy(Parameters.Proxy);
|
SetProxy(Parameters.Proxy);
|
||||||
|
}
|
||||||
|
catch (PlatformNotSupportedException)
|
||||||
|
{
|
||||||
|
// Options are not supported on certain platforms (WebAssembly for instance)
|
||||||
|
// best we can do it try to connect without setting options.
|
||||||
|
}
|
||||||
|
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user