Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 |
//============================================================================= // UdpServerUplink // // Version: 1.3 // // This uplink is compliant with the GameSpy Uplink Specification. // The specification is available at http://www.gamespy.com/developer // and might be of use to progammers who want to adapt their own // server uplinks. // // UdpServerUplink sends a heartbeat to the specified master server // every five minutes. The heartbeat is in the form: // \heartbeat\QueryPort\gamename\unreal // // Full documentation on this class is available at http://unreal.epicgames.com/ // //============================================================================= class UdpServerUplink extends UdpLink config; // Master Uplink Config. var() config bool DoUplink; // If true, do the uplink var() config int UpdateMinutes; // Period of update (in minutes) var() config string MasterServerAddress; // Address of the master server var() config int MasterServerPort; // Optional port that the master server is listening on var() config int Region; // Region of the game server var() name TargetQueryName; // Name of the query server object to use. var IpAddr MasterServerIpAddr; // Master server's address. var string HeartbeatMessage; // The message that is sent to the master server. var UdpServerQuery Query; // The query object. // Initialize. function PreBeginPlay() { // If master server uplink isn't wanted, exit. if( !DoUplink ) { Log("DoUplink is not set. Not connecting to GameSpy."); return; } // Find a the server query handler. foreach AllActors(class'UdpServerQuery', Query, TargetQueryName) break; if( Query==None ) { Log("UdpServerUplink: Could not find a UdpServerQuery object, aborting."); return; } // Set heartbeat message. HeartbeatMessage = "\\heartbeat\\"$Query.Port$"\\gamename\\unreal"; // Set the Port. MasterServerIpAddr.Port = MasterServerPort; // Resolve the Address. if( MasterServerAddress=="" ) MasterServerAddress = "master"$Region$".gamespy.com"; Resolve( MasterServerAddress ); } // When master server address is resolved. function Resolved( IpAddr Addr ) { local bool Result; local int UplinkPort; // Set the address MasterServerIpAddr.Addr = Addr.Addr; // Handle failure. if( MasterServerIpAddr.Addr == 0 ) { Log("UdpServerUplink: Invalid master server address, aborting."); return; } // Display success message. Log("UdpServerUplink: Master Server is "$MasterServerAddress$":"$MasterServerIpAddr.Port); // Bind the local port. UplinkPort = Query.Port + 1; if( !BindPort(UplinkPort, true) ) { Log( "UdpServerUplink: Error binding port, aborting." ); return; } Log("UdpServerUplink: Port "$UplinkPort$" successfully bound."); // Start transmitting. Resume(); } // Host resolution failue. function ResolveFailed() { Log("UdpServerUplink: Failed to resolve master server address, aborting."); } // Notify the MasterServer we exist. function Timer() { local bool Result; Result = SendText( MasterServerIpAddr, HeartbeatMessage ); if ( !Result ) Log( "Failed to send heartbeat to master server."); } // Stop the uplink. function Halt() { Log("UdpServerUplink: Halting by request."); SetTimer(0.0, false); } // Resume the uplink. function Resume() { Log("UdpServerUplink: Resuming by request."); SetTimer(UpdateMinutes * 60, true); Timer(); } defaultproperties { UpdateMinutes=1 MasterServerPort=27900 TargetQueryName=MasterUplink } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |