View Full Version : test connection
pooriapanahi
03-09-2006, 03:56 PM
hi
this is my frist post on this forum :)
i hope u can help me, in this project i used Intrigued's code :
http://www.indigorose.com/forums/sho...67&postcount=5
i wanted to know is there any way to determine if the connection still exist during surifg the web ?
for example running a procces behind the page2, if the connection lost, jump to page3, if not, still on page 2.
i dont know, did i explained what i mean ? ( sorry for my poor english );)
attachment:
http://www.indigorose.com/forums/attachment.php?attachmentid=3188&d=1141901976
I can't find any mistakes in the project attached. What specifically are you trying to do ?
pooriapanahi
03-10-2006, 04:23 PM
what i want to do is :
when the user is on page2 , if connection closed ( disconnected ) automatically page jum to page3 and tell the user " connect to internet and continue "
did i explaned clear ? :rolleyes
Move these
connected = HTTP.TestConnection("http://www.google.com", 20, 80, nil, nil);
if connected then
else
Dialog.Message("Internet Error", "You are not connected to the internet.");
Page.Jump("Page3");
end
From "On Show" to "On Timer" (page 2).
Add this to the "On Show" event (page 2):
Page.StartTimer(100);
pooriapanahi
03-11-2006, 03:41 PM
dear mina
would u pls take a look at my code ?
i did what u told me to do, but it seems somthin' ir wrong :huh 3199
thanks alot :)
Eagle
03-11-2006, 04:48 PM
Hi, what may be more efficient and less disruptive:
try this code in the 'On Navigate' event of your Web Object, no need for on timer stuff:
if (not HTTP.TestConnection("http://www.google.com", 10, 80, nil, nil)) then
Dialog.Message("Internet Error", "You are not connected to the internet.");
Page.Jump("Page3");
end
the idea is test connection only kicks in if an actual 'web page' load is taking place.
(changed 'time out' to 10 seconds)
additionally: another way could be to detect in 'on loaded' event if a 404 error is present in the url
hth
pooriapanahi
03-11-2006, 06:26 PM
wow
thanks eagle, it was a greate idea :)
would u pls tell me about another method ?
Eagle
03-12-2006, 07:29 AM
I modified some http-download-server access error handling functions I
created for an Application-try this modified code that may prove usefull:
--some basic URL-HTTP access error handling
--place below functions in Global Functions if you wish
function HTTP_ErrorCode(strHttpErr)
--[[HTTP Status codes categories:
200-299 Success, 300-399 Information, 400-499 Request error, 500-599 Server error]]
strHttp_Er_disp = "Notice: HTTP related access error";
--some specific staus error returns
if (strHttpErr == 400) then
strHttp_Er_disp = "Unintelligible Request";
elseif (strHttpErr == 404) then
strHttp_Er_disp = "Requested URL not found";
elseif (strHttpErr == 405) then
strHttp_Er_disp = "Server: does not support requested method";
elseif (strHttpErr == 500) then
strHttp_Er_disp = "Server: Unknown Server error";
elseif (strHttpErr == 503) then
strHttp_Er_disp = "Server: Capacity exceeded";
end
return strHttp_Er_disp;
end
function URLAccess()
local nLastError = Application.GetLastError();
local tHTTP_Error = HTTP.GetHTTPErrorInfo();
if ((tHTTP_Error.Number ~= 0) or (nLastError ~= 0)) then
local strerr_header = "Notice: HTTP related access error";
local strurl_error_body = "\r\n- Please check the Internet Connection -\r\n(Settings: Security-Firewall can effect Access)";
local strerr_mess = "";
--error triggers for 'url' related errors
if (tHTTP_Error.Number == 12007) or (tHTTP_Error.Status > 299) then
local strhttp_error_header = HTTP_ErrorCode(tHTTP_Error.Status);
strerr_mess = tHTTP_Error.Message;
if (tHTTP_Error.Status == 404) or (nLastError == 2515) then
strerrhead = strhttp_error_header;
end
end
if (nLastError ~= 2515) then
strerr_mess = "\r\n(".._tblErrorMessages[nLastError]..")";
end
Dialog.Message(strerrheader , strurl_error_body..strerr_mess);
--(add here what actions - returns you wish perform)
Page.Jump("Page3");
end
end
--to call the functionality:
URLAccess(); --try it on a web object's 'on navigate' or 'on loaded' event
hth (try in place of the test connection code) is a lot more code however
should be non instrusive to overall web object performance
Eagle
03-12-2006, 07:47 AM
could also change the functionality call to return true or false:
function URLAccess()
local nLastError = Application.GetLastError();
local tHTTP_Error = HTTP.GetHTTPErrorInfo();
if ((tHTTP_Error.Number ~= 0) or (nLastError ~= 0)) then
local strerr_header = "Notice: HTTP related access error";
local strurl_error_body = "\r\n- Please check the Internet Connection -\r\n(Settings: Security-Firewall can effect Access)";
local strerr_mess = "";
--error triggers for 'url' related errors
if (tHTTP_Error.Number == 12007) or (tHTTP_Error.Status > 299) then
local strhttp_error_header = HTTP_ErrorCode(tHTTP_Error.Status);
strerr_mess = tHTTP_Error.Message;
if (tHTTP_Error.Status == 404) or (nLastError == 2515) then
strerrhead = strhttp_error_header;
end
end
if (nLastError ~= 2515) then
strerr_mess = "\r\n(".._tblErrorMessages[nLastError]..")";
end
Dialog.Message(strerr_header , strurl_error_body..strerr_mess);
return false;
end
reurn true;
end
--to call the functionality:
if (not URLAccess()) then --try it on a web object's 'on navigate' or 'on loaded' event
Page.Jump("Page3");
end
Eagle
03-12-2006, 08:11 AM
syntax errors in the initial urlaccess function:
change: strerrhead
to: strerr_header
for the second posted version of the function only:
change: reurn true;
to: return true;
:wow
pooriapanahi
03-12-2006, 04:46 PM
hi eagle
u mean doing this ?
3206
i'm in page2 and surfing google, i disconnect my internet connection, then i click on a link, a white html page apears, and doesnt go to page 3.
pls check my attached file, and look if every thing is ok ?
thanks a lot :)
Eagle
03-13-2006, 09:12 AM
try this - I also modified the http error function -as some of the code
was not practicle for the web object .
I tested the below and seemed to do what you want in a consistant manner
based on your page method:
hth
pooriapanahi
03-13-2006, 10:38 AM
dear eagle :)
i have same problem, let me tell what did i do:
i went on page2, then disconnected my connection and clicked on a link on google page, then i got a blank page , it did not go to page3 :huh
did u tested like this ?
thanks
Eagle
03-13-2006, 10:50 AM
Yep, did as you requested, many times in fact.
(while in the loaded google page(connected, I disconnetcted, then did a search attempt in google.)
--the code worked ok and jumped to page 3 as expected.
Also jumped to page 3 if disconnected at App runtime.
(you will notice I commented out your 'on show' code to fully test this out)
suggest adding a 'web refresh' action- button to your web object page,
to help test and on a reload of your url see if then consistanly behaves
as you want.
at my end the web object did not display a default IE 'server-url-dns' error 'page' and jumped to your 'page 3'.
Can't offer anything else, maybe some else can chime in with some assistance-workaround-s.
(someone else download it and test it out...)
Eagle
03-13-2006, 11:08 AM
btw: just using the original 4 liner code I posted in the On Loaded event
seemed to work AOK also., maybe fully test that out, if works - use that
code only. :yes
pooriapanahi
03-13-2006, 11:16 AM
thanks dear eagle
i'm realy confused :rolleyes
i hope other guys test it and tell me whats the problem with me :huh
thanks again :)
Eagle
03-13-2006, 11:33 AM
Happ to help - try stuff,Hopefully Yes, web object behaviour may differ according to OS , dll versioning
access calls by the web functionality. Reduce the size of your web object,
place a button object on the same page- button 'on click' event :
Web.LoadURL("Web1", "http://www.google.com");
try the button click when internet disconnected. :yes
pooriapanahi
03-13-2006, 01:49 PM
thanks dear eagle
the button u told me to put on page2, just calls the page ( for example www.google.com ) from my IE history. never prompts " internet conection fails "
thanks again :)
iwtar
03-13-2006, 04:19 PM
i have a little experience in ams6 ,but i think the problem is what eagle mentioned :
web object behaviour may differ according to OS , dll versioning access calls by the web functionality
i had same problem with app.
but i have an other idea.
may be a little swf file, can detect internet connection, for example a flash movie that length 20 sec. and at the last frame, try to connect to a file ( for example a *.txt file ) on the server, if not, goes on a frame . in this frame, with do some action with fscommand :
fscommand("page3");
and in page2's actions :
if e_FSCommand=="page3" then
Page.Jump(page3);
end
what do ya think ? ;)
iwtar
03-13-2006, 04:20 PM
i have a little experience in ams6 ,but i think the problem is what eagle mentioned :
web object behaviour may differ according to OS , dll versioning access calls by the web functionality
i had same problem with app.
but i have an other idea.
may be a little swf file, can detect internet connection, for example a flash movie that length 20 sec. and at the last frame, try to connect to a file ( for example a *.txt file ) on the server, if not, goes on a frame . in this frame, with do some action with fscommand :
fscommand("page3");
and in page2's actions :
if e_FSCommand=="page3" then
Page.Jump(page3);
end
what do ya think ? ;)
iwtar
03-14-2006, 08:21 AM
any body test that ?
any new idea?
Hi iwtar
You will need to return a variable to flash using ASP or PHP.
I also found a plugin for flash, that could do the job
http://www.flashjester.com/index.php?section=tricks_jtools_jnetcheck
Without that plugin, flash itself cannot detect the internet's connection (true/false).
iwtar
03-15-2006, 05:26 AM
hi mina
with actionscript in flash and using some methods to get external informations ( from a server ), flash can do that :)
i'm sure that plugin ( if maden with flash ) is using XMLSocket and trying to connect to an IP Address and a TCP Port. it is a very simple method in flash.
look at this page :
Working with external data in Flash - XMLSocket Class (http://www.devarticles.com/c/a/Flash/Working-with-external-data-in-Flash/5/)
in the attached file, i used another method.
in this example i tried to call a file ( in this case i called for http://www.indigorose.com/site/index.php ) and checked if can access through this file =>true , else=>false.
in the false frame , i used fscommand("page3")
just take a look.
with nums of frames and FPS ( frame per seccound ) we can control timer for checkin network connection :)
iwtar
03-15-2006, 05:28 AM
sorry i forgot to attache the example :D
3213
Hi
Is it ok to post the source .fla flash movie file ?
i'm interested in taking a look at the scripts..
TIA
iwtar
03-15-2006, 06:36 AM
hi mina
did u test that ?
this is the fla file. take a look :)
3214
have a good time
thanks for sharing. :yes
I'll check the file when i return home tomorrow because the laptop im using doesn't have macromedia flash in it.
pooriapanahi
03-15-2006, 04:58 PM
thanks for sharing iwtar. but sorry, i dont know flash and i prefer to use just ams.
thanks anyway ;)
iwtar
03-16-2006, 04:51 AM
thanks every body for testing :)
its oh pooria, are you hamvatan ?:cool
i'm going to develope this method, i think it would be better than using webobjects
pooriapanahi
03-17-2006, 05:30 PM
hi iwtar
yes, i am hamvatan ;)
thank u for submiting your method, i'm intrested to know what other people think about your method
bye
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.