MozillaZine

Can extension get connection status in background?

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

Post Posted October 28th, 2016, 6:06 pm

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: 3663
Joined: September 15th, 2010, 9:03 am

Post Posted October 29th, 2016, 2:58 pm

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

Post Posted November 4th, 2016, 10:16 am

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:)

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest