Open MaximLipnin opened 4 years ago
Tagging subscribers to this area: @dotnet/ncl Notify danmosemsft if you want to be subscribed.
How should the .NET API behave when the browser API is not available?
We have several situations that can happen
We could deal with it in these ways
Cannot read properties of undefined (reading 'onLine')
when navigator is not there)
NotSupportedException
)
cc @lewing @pavelsavara @kg
For NetworkInterface.GetIsNetworkAvailable
:
navigator.onLine
works, so we're just hoping that it's close enough to what we want. The MDN pages at least suggest it is, so that's good. But we should be wary of making existing good code do strange things by redefining the meaning of this information.For the NetworkChange.NetworkAvailabilityChanged
event I think as long as it is theoretically possible for the event to ever fire, it should be fine to subscribe to it, but we should throw NSE
or PNSE
if it's never going to work. We would want to use the online
/offline
events for this.
Keep in mind that both of these are probably at risk of getting killed by browser anti-fingerprinting measures or something like that.
Since we don't have access to the network cards on browser/WASM, the entire System.Net.NetworkInformation assembly is going to be PNSE excepting tho methods:
These two methods could probably be implemented on top of https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine