IpDrv
Class UdpBeacon

source: e:\games\UnrealTournament\IpDrv\Classes\UdpBeacon.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.InternetInfo
            |
            +--IpDrv.InternetLink
               |
               +--IpDrv.UdpLink
                  |
                  +--IpDrv.UdpBeacon
Direct Known Subclasses:ClientBeaconReceiver

class UdpBeacon
extends IpDrv.UdpLink

//============================================================================= // UdpBeacon: Base class of beacon sender and receiver. //=============================================================================
Variables
 int BeaconPort
           Reply port
 string BeaconProduct
           Reply port
 float BeaconTimeout
           Reply port
 bool DoBeacon
 int ServerBeaconPort
           Listen port
 int UdpServerQueryPort
           Reply port
 int boundport
           Reply port


Function Summary
 void BeginPlay()
 void BroadcastBeacon(IpAddr Addr)
 void BroadcastBeaconQuery(IpAddr Addr)
 void Destroyed()



Source Code


00001	//=============================================================================
00002	// UdpBeacon: Base class of beacon sender and receiver.
00003	//=============================================================================
00004	class UdpBeacon extends UdpLink
00005		config
00006		transient;
00007	
00008	var() globalconfig bool       DoBeacon;
00009	var() globalconfig int        ServerBeaconPort;		// Listen port
00010	var() globalconfig int        BeaconPort;			// Reply port
00011	var() globalconfig float      BeaconTimeout;
00012	var() globalconfig string     BeaconProduct;
00013	
00014	var int	UdpServerQueryPort;
00015	var int boundport;
00016	
00017	function BeginPlay()
00018	{
00019		local IpAddr Addr;
00020	
00021		boundport = BindPort(ServerBeaconPort, True);
00022		if ( boundport == 0 )
00023		{
00024			log( "UdpBeacon failed to bind a port." );
00025			return;
00026		}
00027	
00028		Addr.Addr = BroadcastAddr;
00029		Addr.Port = BeaconPort;
00030		BroadcastBeacon(Addr); // Initial notification.
00031	}
00032	
00033	function BroadcastBeacon(IpAddr Addr)
00034	{
00035		SendText( Addr, BeaconProduct @ Mid(Level.GetAddressURL(),InStr(Level.GetAddressURL(),":")+1) @ Level.Game.GetBeaconText() );
00036		//Log( "UdpBeacon: sending reply to "$IpAddrToString(Addr) );
00037	}
00038	
00039	function BroadcastBeaconQuery(IpAddr Addr)
00040	{
00041		SendText( Addr, BeaconProduct @ UdpServerQueryPort );
00042		//Log( "UdpBeacon: sending query reply to "$IpAddrToString(Addr) );
00043	}
00044	
00045	event ReceivedText( IpAddr Addr, string Text )
00046	{
00047		if( Text == "REPORT" )
00048			BroadcastBeacon(Addr);
00049	
00050		if( Text == "REPORTQUERY" )
00051			BroadcastBeaconQuery(Addr);
00052	}
00053	
00054	function Destroyed()
00055	{
00056		Super.Destroyed();
00057		//Log("ServerBeacon Destroyed");
00058	}
00059	
00060	defaultproperties
00061	{
00062	     DoBeacon=True
00063	     ServerBeaconPort=8777
00064	     BeaconPort=9777
00065	     BeaconTimeout=5.000000
00066	     BeaconProduct="ut"
00067	     RemoteRole=ROLE_None
00068	}

End Source Code