Skip to content

Commit

Permalink
Merge pull request #283 from bjorg/issue_280
Browse files Browse the repository at this point in the history
check if running in WebAssembly instead of catching PlatformNotSupportedException
  • Loading branch information
rose-a authored Sep 17, 2020
2 parents 3483e8e + 7fe7137 commit 61373d7
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,22 +408,12 @@ public Task InitializeWebSocket()
#else
_clientWebSocket = new ClientWebSocket();
_clientWebSocket.Options.AddSubProtocol("graphql-ws");
try
if(!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Create("WEBASSEMBLY")))
{
// the following properties are not supported in Blazor WebAssembly and throw a PlatformNotSupportedException error when accessed
_clientWebSocket.Options.ClientCertificates = ((HttpClientHandler)Options.HttpMessageHandler).ClientCertificates;
}
catch (PlatformNotSupportedException)
{
Debug.WriteLine("unable to set Options.ClientCertificates property; platform does not support it");
}
try
{
_clientWebSocket.Options.UseDefaultCredentials = ((HttpClientHandler)Options.HttpMessageHandler).UseDefaultCredentials;
}
catch (PlatformNotSupportedException)
{
Debug.WriteLine("unable to set Options.UseDefaultCredentials property; platform does not support it");
}
Options.ConfigureWebsocketOptions(_clientWebSocket.Options);
#endif
return _initializeWebSocketTask = ConnectAsync(_internalCancellationToken);
Expand Down Expand Up @@ -627,7 +617,7 @@ public void Complete()

/// <summary>
/// Task to await the completion (a.k.a. disposal) of this websocket.
/// </summary>
/// </summary>
/// Async disposal as recommended by Stephen Cleary (https://blog.stephencleary.com/2013/03/async-oop-6-disposal.html)
public Task? Completion { get; private set; }

Expand Down

0 comments on commit 61373d7

Please sign in to comment.