UBrowser
Class UBrowserUpdateServerLink

source: c:\runehov\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:RBrowserUpdateServerLink

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	log("browse:"$UpdateServerAddress@URIs[CurrentURI]@":"$UpdateServerPort);
00035		Browse(UpdateServerAddress, URIs[CurrentURI], UpdateServerPort, UpdateServerTimeout);
00036	}
00037	
00038	function Failure()
00039	{
00040		UpdateWindow.Failure();
00041	}
00042	
00043	function Success()
00044	{
00045		UpdateWindow.Success();
00046	}
00047	
00048	function ProcessData(string Data)
00049	{
00050		switch(CurrentURI)
00051		{
00052		case GetMOTD:
00053		case GetFallback:
00054			UpdateWindow.SetMOTD(Data);
00055			break;
00056		case GetMaster:
00057			UpdateWindow.SetMasterServer(Data);
00058			break;
00059		case GetIRC:
00060			UpdateWindow.SetIRCServer(Data);
00061			break;
00062		}
00063	}
00064	
00065	//////////////////////////////////////////////////////////////////
00066	// HTTPClient functions
00067	//////////////////////////////////////////////////////////////////
00068	
00069	function HTTPError(int ErrorCode)
00070	{	
00071		if(ErrorCode == 404 && CurrentURI == GetMOTD)
00072		{
00073			CurrentURI = GetFallback;
00074			BrowseCurrentURI();
00075		}
00076		else
00077			Failure();
00078	}
00079	
00080	function HTTPReceivedData(string Data)
00081	{
00082		ProcessData(Data);
00083	
00084		if(CurrentURI == MaxURI)
00085			CurrentURI--;
00086	
00087		if(CurrentURI == 0)
00088			Success();
00089		else
00090		{
00091			CurrentURI--;
00092			BrowseCurrentURI();
00093		}
00094	}
00095	
00096	defaultproperties
00097	{
00098	     UpdateServerAddress="www.runegame.com"
00099	     UpdateServerPort=80
00100	     UpdateServerTimeout=5
00101	}

End Source Code