Open TrickMe opened 2 years ago
Not sure about the method name or required implementation, but the use case and the problem make sense to me. Some games even display a "Connection issue" icon to alleviate the problem and convey this to a player.
Perhaps this can be detected by checking the ping instead?
Perhaps this can be detected by checking the ping instead?
The issue is… which server do we check the ping against? Checking for an Internet connection should be possible even if you're not currently connected to a server. Also, we should not make Godot depend on a central server. Instead, querying the OS API is the way to go, but it can be surprisingly difficult on Windows if I'm not mistaken.
Another thing we should be careful about is distinguishing between "is the local network reachable?" and "is the Internet reachable?". For instance, for a game with player-hosted servers, you should not query Internet access to block access to a multiplayer menu, as LAN play is still possible this way.
It can be surprisingly difficult on Windows if I'm not mistaken.
I believe this should be possible using the Network List Manager API.
Personally, I think that this feature would fit better into a Network
singleton, so that the OS class isn't getting too bloated with miscellaneous methods. However, a new singleton might be overkill for just this feature, so it would be better if there were other features that could be moved/added to Network
as well.
If it's considered a small enough change that it's okay despite the feature freeze, I would be happy to implement this feature!
Describe the project you are working on
Space X4 with multiplayer over websocket
Describe the problem or limitation you are having in your project
If my internet is disconnected, my game client just keep running, instead of e.g. pausing the game and trying to reconnect.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Ability to check if internet is connected and can resolve urls. Signal that notifies, if internet was just connected/disconnected.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Check internet connection:
bool OS.is_internet_connected()
Signals:
OS.internet_connected()
OS.internet_disconnected()
If this enhancement will not be used often, can it be worked around with a few lines of script?
Multiplayer games will make use of it. Can not, to my knowledge, be worked around with a few lines of code.
Is there a reason why this should be core and not an add-on in the asset library?
Multiplayer games must be able to check if the client has a working internet connection.