TrueUpdate.GetServerFile

boolean TrueUpdate.GetServerFile ( 

string   ServerID,

boolean  ShowRestartDialog = true,

function CallbackFunction = nil )

Description

Attempts to download and load the server configuration files from a specific TrueUpdate Server.

Note: This action also updates the client files if needed. If the client files require updating, a notification dialog will be shown, the update process is restarted, and the global variable _ClientRestarted is set to true.

Parameters

ServerID

(string) The Name/ID of the TrueUpdate Server you want to get the server configuration files from.

ShowRestartDialog

(boolean) Whether to show the restart dialog if the client needs to be restarted when a new client executable or client .dat file is availalable:

VALUE

DESCRIPTION

true

Show a dialog notifying that the client needs to be restarted. (Default)

false

Restart the client without a notification dialog.

CallbackFunction

(function) The name of a function that will be called whenever progress is made in the download operation of the server configuration files. (You can use this callback function to display the progress of the download in your own custom way.)

Note: If CallbackFunction is set to nil, then the progress information will be sent to the built-in status dialog, assuming it is currently visible. (You can show or hide the status dialog with a StatusDlg.Show or StatusDlg.Hide action.)

The callback function must be able to receive the following parameters:

BytesRead

(number) The number of bytes that have been downloaded so far.

FileSize

(number) The file size in bytes or 0 if the file size could not be retrieved from the server.

TransferRate

(number) The current transfer rate in Kilobytes per second.

SecondsLeft

(number) The estimated number of seconds left in the download.

SecondsLeftFormat

(string) The estimated number of seconds left formatted as a string in the form of: ""MM:SS".

Message

(string) Either a blank string ("") or an information message being sent by the server, such as "Resolving host name" or "Connecting to Server."

Note: If this parameter is not a blank string, it means that it is in a busy state, either before the download has begun, or at the end of the download. In this case all other parameters will be ignored.

UpdateInfo

(table) A table containing update information for the new client files indexed by the following categories. If the client files do not need to be updated, nil is returned.

KEY

TYPE

DESCRIPTION

UpdateType

number

The type of update being performed. If 0 is returned, the client executable (.ts3) is being downloaded. If 1 is returned, the client data  file (.ts2) is being downloaded. You can access this value using tb.UpdateType.

UpdateFile

string

The full path to the current file that is being downloaded. For example: ftp://myftp.ftp/files/update.ts2. You can access this value using tb.UpdateFile.

UpdateVersion

string

The version of the client executable that is being downloaded. You can access this value using tb.UpdateVersion.

 

The callback function should return a boolean value (true or false) indicating whether the download should continue:

VALUE

DESCRIPTION

true

Continue with the file download.

false

Stop the file download as soon as possible.

Returns

(boolean) True if the server configuration file was downloaded and loaded successfully, or false if it was not or an error occurs.  You can use Application.GetLastError to determine whether this action failed, and why.

ResultVariable

When adding an action with the action editor, you can use this field to specify a variable that the return value will be stored in.

See also:  Related Actions