|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Detecting a network connection - can it be done - how?
Is there a component bundled with the Mozilla build to detect when a connection to the internet is established. The standalone XUL app that I am working on requires an ongoing connection to connect to a remote server. I would like to prompt the user with a box notifying them if their computer is not connected at application start-up, or application onload().
Any insight on this will be greatly appreciated....
__________________
~ Joe Penn |
|
#2
|
|||
|
|||
|
Joe,
Do you mean to detect when the computer itself is connected to the web, or just when the Mozilla component is able or unable to make a connection? If it is the second case, I would think that all you have to do is query for a specific response string on the remote server, and if there is no response (if the string is null), then you pop up the box.
__________________
The real n-tier system: FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL Amazon wishlist -- rycamor (at) gmail.com Last edited by rycamor : October 29th, 2002 at 06:24 PM. |
|
#3
|
||||
|
||||
|
Well, the second question to your reply should work fine. Generally, I need a way to send a var to the javascript function saying that a connection to the web could'nt be found, that way I can present the user with an alert or window notifying them. Not really sure how to go about this. There is really no viable resources as of yet to get any kind of insight on this.
The app I am writing will finish up one of our CMS system so I can put this behind me. Also, I am writing a tutorial on this app as I go so we can use it in our plans...... ![]() |
|
#4
|
|||
|
|||
|
To get a little more sophisticated about it, though, we might try digging into the XPCOM API a little, at http://www.xulplanet.com/references...-hierarchy.html
So far, the methods that looked interesting are nsINetNotify, nsIHttpNotify, or the nsIRequestObserver object. |
|
#5
|
|||
|
|||
|
Quote:
(or should I say Xool?). |
|
#6
|
||||
|
||||
|
P.S. -> While the O'Riley 'Creating Applications with Mozilla' is a great piece of work, it still does not cover alot - and I mean alot of stuff on this. Worth the 40 bucks, but we still need better books for reference.....
![]() |
|
#7
|
|||
|
|||
|
You've got me curious now, so I'm toying with the XMLHttpRequest() class. Is your app a signed or unsigned app?
|
|
#8
|
||||
|
||||
|
Quote:
It will be unsigned.... |
|
#9
|
||||
|
||||
|
Ok, using the window widget I can use the onload() event . I am starting to think that maybe I can send a ping to the remote server and check for a return on it, pretty much what you suggested at first rycamor. That would tell me if a connection is established. Now I just need to figure out how to send the request to the server and check against that...
|
|
#10
|
|||
|
|||
|
Well it looks like most of the serious networking stuff is not available for unsigned apps. I am still trying to figure out just what the boundaries are. Signed apps are fairly simple though: they just pop up a window asking the user to authorize certain types of actions, and even if they want to "remember" this choice.
But for your unsigned version, I can see it this way: have a small function that writes a script tag pair, with the SRC attribute being a .js file on your server. This .js file will simply set a single Javascript variable. That is it's only execution task. But, your function which makes this happen will check for the value of that variable. If the value is set as expected, it can continue, but if the variable is NOT set as expected, open an alert. Or, you could use the old trick of the small hidden<iframe> which refreshes every few seconds to run a small script supplied by the server. |
|
#11
|
|||
|
|||
|
Did this work for you?
Hi,
I tried to get this to work but couldn't. Did you ever get it to work? Thanks!!! Pete |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Detecting a network connection - can it be done - how? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|