## IpDrv
Class UdpBeacon

source: C:\XIII\IpDrv\Classes\UDPBEACON.UC

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--Engine.InternetInfo
                |
                +--IpDrv.InternetLink
                   |
                   +--IpDrv.UdpLink
                      |
                      +--IpDrv.UdpBeacon

Direct Known Subclasses:XBOXServerBeacon, XBOXClientBeaconReceiver, 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		native
    00006		config
    00007		transient;
    00008
    00009	var() globalconfig bool       DoBeacon;
    00010	var() globalconfig int        ServerBeaconPort;		// Listen port
    00011	var() globalconfig int        BeaconPort;			// Reply port
    00012	var() globalconfig float      BeaconTimeout;
    00013	var() globalconfig string     BeaconProduct;
    00014
    00015	var int	UdpServerQueryPort;
    00016	var int boundport;
    00017
    00018	function BeginPlay()
    00019	{
    00020		//local IpAddr Addr;
    00021
    00022		boundport = BindPort(ServerBeaconPort, True);
    00023		if ( boundport == 0 )
    00024		{
    00025			log( "UdpBeacon failed to bind a port." );
    00026			return;
    00027		}
    00028
    00029	    // Useless to broadcast now, since a lot is yet to be done before the level is running !
    00030	    // (it avoids an annoying flick in join lan game menu (server appears-disappears-appears while loading))
    00031		/*
    00032		Addr.Addr = BroadcastAddr;
    00033		Addr.Port = BeaconPort;
    00034		BroadcastBeacon(Addr); // Initial notification.
    00035	    */
    00036	}
    00037
    00038	function BroadcastBeacon(IpAddr Addr)
    00039	{
    00040	    local string S;
    00041	    S = Mid(Level.GetAddressURL(),InStr(Level.GetAddressURL(),":")+1);
    00042		SendText( Addr, BeaconProduct @ S @ Level.Game.GetBeaconText() );
    00043		//Log( "UdpBeacon: BroadcastBeacon("$BeaconProduct @ S @ Level.Game.GetBeaconText()$") to "$IpAddrToString(Addr) );
    00044	}
    00045
    00046	function BroadcastBeaconQuery(IpAddr Addr)
    00047	{
    00048		SendText( Addr, BeaconProduct @ UdpServerQueryPort );
    00049		//Log( "UdpBeacon: BroadcastBeaconQuery("$BeaconProduct @ UdpServerQueryPort$") to "$IpAddrToString(Addr) );
    00050	}
    00051
    00052	event ReceivedText( IpAddr Addr, string Text )
    00053	{
    00054		if( Text == "REPORT" )
    00055			BroadcastBeacon(Addr);
    00056
    00057		if( Text == "REPORTQUERY" )
    00058			BroadcastBeaconQuery(Addr);
    00059	}
    00060
    00061	function Destroyed()
    00062	{
    00063		Super.Destroyed();
    00064		//Log("ServerBeacon Destroyed");
    00065	}
    00066
    00067	defaultproperties
    00068	{
    00069	     DoBeacon=True
    00070	     ServerBeaconPort=8777
    00071	     BeaconPort=9777
    00072	     BeaconTimeout=5.000000
    00073	     BeaconProduct="XIII"
    00074	     RemoteRole=ROLE_None
    00075	}

End Source Code