UBrowser
Class UBrowserUpdateServerLink

source: e:\games\UnrealTournament\UBrowser\Classes\UBrowserUpdateServerLink.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.InternetInfo
            |
            +--IpDrv.InternetLink
               |
               +--IpDrv.TcpLink
                  |
                  +--UBrowser.UBrowserBufferedTcpLink
                     |
                     +--UBrowser.UBrowserHTTPClient
                        |
                        +--UBrowser.UBrowserUpdateServerLink
Direct Known Subclasses:UTBrowserUpdateServerLink

class UBrowserUpdateServerLink
extends UBrowser.UBrowserHTTPClient


Variables
 int CurrentURI
 int MaxURI
 string URIs[10]
 string UpdateServerAddress
 int UpdateServerPort
 int UpdateServerTimeout
 UBrowserUpdateServerWindow UpdateWindow


Function Summary
 void BrowseCurrentURI()
 void Failure()
 void HTTPError(int ErrorCode)
     
//////////////////////////////////////////////////////////////////
// HTTPClient functions
//////////////////////////////////////////////////////////////////
 void HTTPReceivedData(string Data)
 void ProcessData(string Data)
 void QueryUpdateServer()
 void SetupURIs()
 void Success()



Source Code


00001	class UBrowserUpdateServerLink expands UBrowserHTTPClient;
00002	
00003	var config string		UpdateServerAddress;
00004	var config int			UpdateServerPort;
00005	var config int			UpdateServerTimeout;
00006	var string				URIs[10];
00007	var int					CurrentURI;
00008	var int					MaxURI;
00009	var UBrowserUpdateServerWindow	UpdateWindow;
00010	
00011	const GetMOTD = 3;
00012	const GetFallback = 2;
00013	const GetMaster = 1;
00014	const GetIRC = 0;
00015	
00016	function QueryUpdateServer()
00017	{
00018		SetupURIs();
00019		CurrentURI = MaxURI;
00020		BrowseCurrentURI();
00021	}
00022	
00023	function SetupURIs()
00024	{
00025		MaxURI = 3;
00026		URIs[3] = "/UpdateServer/motd"$Level.EngineVersion$".html";
00027		URIs[2] = "/UpdateServer/motdfallback.html";
00028		URIs[1] = "/UpdateServer/masterserver.txt";
00029		URIs[0] = "/UpdateServer/ircserver.txt";
00030	}
00031	
00032	function BrowseCurrentURI()
00033	{
00034		Browse(UpdateServerAddress, URIs[CurrentURI], UpdateServerPort, UpdateServerTimeout);
00035	}
00036	
00037	function Failure()
00038	{
00039		UpdateWindow.Failure();
00040	}
00041	
00042	function Success()
00043	{
00044		UpdateWindow.Success();
00045	}
00046	
00047	function ProcessData(string Data)
00048	{
00049		switch(CurrentURI)
00050		{
00051		case GetMOTD:
00052		case GetFallback:
00053			UpdateWindow.SetMOTD(Data);
00054			break;
00055		case GetMaster:
00056			UpdateWindow.SetMasterServer(Data);
00057			break;
00058		case GetIRC:
00059			UpdateWindow.SetIRCServer(Data);
00060			break;
00061		}
00062	}
00063	
00064	//////////////////////////////////////////////////////////////////
00065	// HTTPClient functions
00066	//////////////////////////////////////////////////////////////////
00067	
00068	function HTTPError(int ErrorCode)
00069	{	
00070		if(ErrorCode == 404 && CurrentURI == GetMOTD)
00071		{
00072			CurrentURI = GetFallback;
00073			BrowseCurrentURI();
00074		}
00075		else
00076			Failure();
00077	}
00078	
00079	function HTTPReceivedData(string Data)
00080	{
00081		ProcessData(Data);
00082	
00083		if(CurrentURI == MaxURI)
00084			CurrentURI--;
00085	
00086		if(CurrentURI == 0)
00087			Success();
00088		else
00089		{
00090			CurrentURI--;
00091			BrowseCurrentURI();
00092		}
00093	}
00094	
00095	defaultproperties
00096	{
00097	     UpdateServerAddress="unreal.epicgames.com"
00098	     UpdateServerPort=80
00099	     UpdateServerTimeout=5
00100	}

End Source Code