PDA

View Full Version : How to get the "Location" out of the server list


davedoc
08-12-2008, 01:18 AM
In my client script I have managed to get the table of TrueUpdate servers and iterate over that to find a good one using GetServerFile().

I'm now working in the server file and need to pull the "location" attribute out of the Server that I ended up connecting to. For instance right now I just have this coded to
g_SourceURL = "myserver.com/updates/myProduct/update_" .. g_AvailableVersion .. ".exe"

I need to find a way to iterate over the list again and replace the myserver.com with the name where I downloaded the server script file from in the client.

I've looked through the help and I can see that I'll probably use HTTP.TestConnection to see if I have a connection to each URL, but how can I iterate over the list pulling the location attribute?

upeters
08-12-2008, 01:54 PM
Unless I misunderstood what you are trying to do, I think you won't need to do any additional iteration once you have found a valid location of the server files.

You said that you found an active server with GetServerFile(). I assume that you were looking at the "Download Server Script" screen, in the "On Start" event, weren't you? There you see that the loop will break once a valid server is found.

So, all you have to do is save the ServerName in a new global variable to be able to use it again where you need it to. For example, you could change this code

-- Break out of this loop if we succeeded
if(screen_globals.GotServerFiles) then
break;
end;

to this:

-- Break out of this loop if we succeeded
if(screen_globals.GotServerFiles) then
-- before leaving the screen, save the server name
g_servername = ServerName;
break;
end;

After this, you might want to use the new variable you created to set the correct filename you will try to download afterwards. In other words, before you use the g_SourceURL in your download screen action, change it to something like
g_SourceURL = g_servername .. "/updates/myProduct/update_" .. g_AvailableVersion .. ".exe".

Please check if this works, if that was indeed what you were trying.

Also, see this post (http://www.indigorose.com/forums/showthread.php?p=115399#post115399).

Ulrich

davedoc
08-21-2008, 08:04 AM
I fixed it by just hard coding the url in HTTP.TestConnection. We only have 2 servers so it's not a big deal.