Can extension get connection status in background?

Talk about add-ons and extension development.
Post Reply
thusimon
Posts: 4
Joined: January 13th, 2016, 11:00 am

Can extension get connection status in background?

Post by thusimon »

Hi All,
My extension would like to keep track of the internet connection status, I found this navigator.online attribute and event
https://developer.mozilla.org/en-US/doc ... ine_events
But it is related to the content page (using window.navigator...), and event registering would be like "window.addEventListener("offline", func)".
The shortcoming is if I have 10 tabs opened, then the connection is down, the offline event will be triggered 10 times
Is there any other API to achieve this in the background? So I will only get one event if the connection status change
Thanks
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Can extension get connection status in background?

Post by lithopsian »

For an addon, use the observer notification network:offline-status-changed. The data value contains the string "online" or "offline" in case you didn't remember it.
thusimon
Posts: 4
Joined: January 13th, 2016, 11:00 am

Re: Can extension get connection status in background?

Post by thusimon »

lithopsian wrote:For an addon, use the observer notification network:offline-status-changed. The data value contains the string "online" or "offline" in case you didn't remember it.
That's it, Thank you very much lithopsian:)
Post Reply