Page 1 of 1

Internet access

Posted: Mon Aug 16, 2021 2:33 am
by anmldr
I now live in Costa Rica. Internet access is frequently unavailable at my house...many places in Costa Rica, really. It is on-off-on frequently. Is there a command or function in LC that can check the status of a connection while the app is running in the background? This would be for all platforms. This way I would not need to constantly check on it myself. I could be doing other tasks that do not require access and be alerted when the Internet is available again.

Thanks,
Linda

Re: Internet access

Posted: Mon Aug 16, 2021 3:53 am
by andresdt
There are things I don't know how to do, for example make the app run as a background system service. I know that in Win it is possible and that in Android it is not. In the rest of the platforms I have no idea. But here I share something that can help you.

Code: Select all

on mouseUp
    __InternetMonitor
end mouseUp 

constant kURL = "http://detectportal.firefox.com/"
command __InternetMonitor
    unload URL kURL
    load URL kURL with message "InternetStatus"
end __InternetMonitor

local sLastStatus
on InternetStatus pURL, pStatus
    if pURL is kURL then
        if pStatus is not "cached" then
            put pStatus into sLastStatus
            -- Not Internet
        else
            if sLastStatus is no pStatus then
                put pStatus into sLastStatus
                put url pURL
                beep
                -- Launch App or URL
                answer warning "Internet"
            end if
        end if
    end if
    
    send "__InternetMonitor" to me in 1 sec
end InternetStatus