Open kblok opened 5 years ago
I bet CreateClientWebSocket returns a WebSocket because both Managed.ClientWebSocket and ClientWebSocket inherits from WebSocket.
WebSocket
Managed.ClientWebSocket
ClientWebSocket
The problem is that it hides the Options property. If I want to set the KeepAliveInterval should I do something like this?
Options
KeepAliveInterval
var client = SystemClientWebSocket.CreateClientWebSocket(); if (client is System.Net.WebSockets.Managed.ClientWebSocket managed) { managed.Options.KeepAliveInterval = TimeSpan.FromSeconds(0); await managed.ConnectAsync(uri, cancellationToken); } else { var coreSocket = client as ClientWebSocket; coreSocket.Options.KeepAliveInterval = TimeSpan.FromSeconds(0); await coreSocket.ConnectAsync(uri, cancellationToken); }
If think one option would be passing the Options as an argument to the ConnectAsync method.
ConnectAsync
Alternatively, a helper function in the form of SystemClientWebSocket.SetKeepAliveInterval(WebSocket ws, TimeSpan interval) would be helpful too...
I bet CreateClientWebSocket returns a
WebSocket
because bothManaged.ClientWebSocket
andClientWebSocket
inherits fromWebSocket
.The problem is that it hides the
Options
property. If I want to set theKeepAliveInterval
should I do something like this?If think one option would be passing the
Options
as an argument to theConnectAsync
method.