Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 30

Thread: test connection

  1. #1
    Join Date
    Feb 2006
    Posts
    12

    Grin test connection

    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/att...8&d=1141901976

  2. #2
    Join Date
    Oct 2005
    Location
    American Dubai
    Posts
    629
    I can't find any mistakes in the project attached. What specifically are you trying to do ?

  3. #3
    Join Date
    Feb 2006
    Posts
    12

    connection

    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 ?

  4. #4
    Join Date
    Oct 2005
    Location
    American Dubai
    Posts
    629
    Move these
    Code:
    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):
    Code:
    Page.StartTimer(100);

  5. #5
    Join Date
    Feb 2006
    Posts
    12

    nothing happend

    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 test internet.apz
    thanks alot

  6. #6
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    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:

    Code:
    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
    Last edited by Eagle; 03-11-2006 at 03:58 PM.

  7. #7
    Join Date
    Feb 2006
    Posts
    12

    thanks :)

    wow
    thanks eagle, it was a greate idea
    would u pls tell me about another method ?

  8. #8
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    I modified some http-download-server access error handling functions I
    created for an Application-try this modified code that may prove usefull:

    Code:
    --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
    Last edited by Eagle; 03-12-2006 at 06:40 AM.

  9. #9
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    could also change the functionality call to return true or false:

    Code:
    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
    Last edited by Eagle; 03-12-2006 at 07:01 AM.

  10. #10
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    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;

    Last edited by Eagle; 03-12-2006 at 07:14 AM.

  11. #11
    Join Date
    Feb 2006
    Posts
    12

    thanks

    hi eagle
    u mean doing this ?
    test internet connection.apz

    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

  12. #12
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    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
    Attached Files
    Last edited by Eagle; 03-13-2006 at 08:15 AM.

  13. #13
    Join Date
    Feb 2006
    Posts
    12

    still have problem

    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
    did u tested like this ?

    thanks

  14. #14
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    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...)
    Last edited by Eagle; 03-13-2006 at 10:03 AM.

  15. #15
    Join Date
    Mar 2005
    Location
    WA 'wait a while' - Australia
    Posts
    872
    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.

Page 1 of 2 1 2 LastLast

Similar Threads

  1. test connection
    By pooriapanahi in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 03-09-2006, 04:04 AM
  2. Check For Internet connection?
    By Roboblue in forum AutoPlay Media Studio 5.0
    Replies: 1
    Last Post: 02-01-2005, 04:40 PM
  3. Replies: 2
    Last Post: 07-11-2003, 10:13 AM
  4. Test
    By Bruce in forum AutoPlay Media Studio 4.0
    Replies: 10
    Last Post: 10-05-2002, 01:03 PM
  5. Dialup Connection
    By sdmeier in forum Setup Factory 5.0
    Replies: 1
    Last Post: 11-02-2000, 10:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts