dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.48k stars 4.76k forks source link

[wasm] Implement NetworkInterface.GetIsNetworkAvailable and NetworkChange.NetworkAvailabilityChanged #38988

Open MaximLipnin opened 4 years ago

MaximLipnin commented 4 years ago

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

ghost commented 4 years ago

Tagging subscribers to this area: @dotnet/ncl Notify danmosemsft if you want to be subscribed.

lewing commented 2 years ago

https://developer.mozilla.org/en-US/docs/Web/API/Network_Information_API

maraf commented 2 years ago

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

cc @lewing @pavelsavara @kg

kg commented 2 years ago

For NetworkInterface.GetIsNetworkAvailable:

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.