XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 29th, 2002, 06:07 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
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

Reply With Quote
  #2  
Old October 29th, 2002, 06:21 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
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.

Reply With Quote
  #3  
Old October 29th, 2002, 06:33 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
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......

Reply With Quote
  #4  
Old October 29th, 2002, 06:34 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
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.

Reply With Quote
  #5  
Old October 29th, 2002, 06:36 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
Quote:
Originally posted by jpenn
Also, I am writing a tutorial on this app as I go so we can use it in our plans......
Cool (or should I say Xool?).

Reply With Quote
  #6  
Old October 29th, 2002, 06:41 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
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.....

Reply With Quote
  #7  
Old October 29th, 2002, 07:15 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
You've got me curious now, so I'm toying with the XMLHttpRequest() class. Is your app a signed or unsigned app?

Reply With Quote
  #8  
Old October 29th, 2002, 07:18 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
Quote:
You've got me curious now, so I'm toying with the XMLHttpRequest() class. Is your app a signed or unsigned app?

It will be unsigned....

Reply With Quote
  #9  
Old October 29th, 2002, 07:36 PM
jpenn's Avatar
jpenn jpenn is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2002
Location: Washington, DC
Posts: 2,693 jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level)jpenn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 41 m 10 sec
Reputation Power: 16
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...

Reply With Quote
  #10  
Old October 29th, 2002, 07:46 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Pembroke Pines, Florida, USA
Posts: 2,300 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 3 h 12 m 27 sec
Reputation Power: 53
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.

Reply With Quote
  #11  
Old February 11th, 2004, 11:31 AM
trimblepb trimblepb is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 trimblepb User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Detecting a network connection - can it be done - how?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |