Update network manager to utilize gonetworkmanager for an easier life...
This commit is contained in:
@@ -204,25 +204,16 @@ func (app *Application) checkState() {
|
||||
// Check if there is an internet connection, and if not, force the WiFi page
|
||||
if !networkIsUp {
|
||||
if lastNetworkCheckTime.IsZero() || time.Since(lastNetworkCheckTime) >= time.Second {
|
||||
networkManager, err := network.New()
|
||||
if err != nil {
|
||||
logger.Error("error obtaining a network manager %v", err)
|
||||
return
|
||||
}
|
||||
lastNetworkCheckTime = time.Now()
|
||||
status, err := networkManager.CheckInternetConnection()
|
||||
if err != nil {
|
||||
logger.Error("error checking for internet connection %v", err)
|
||||
return
|
||||
}
|
||||
if status.StatusCode != network.StatusWifiConnectedInternetUp &&
|
||||
status.StatusCode != network.StatusEthernetConnectedInternetUp {
|
||||
|
||||
if !network.HasInternet() {
|
||||
if app.state != NEEDS_INTERNET {
|
||||
app.PageRouter.NavigateTo(page.WIFI)
|
||||
app.state = NEEDS_INTERNET
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
networkIsUp = true // internet confirmed, don't check again
|
||||
} else {
|
||||
return // throttled, and we don't yet know if network is up — can't proceed
|
||||
|
||||
Reference in New Issue
Block a user