## IpDrv
Class XBOXClientBeaconReceiver

source: C:\XIII\IpDrv\Classes\XBOXClientBeaconReceiver.uc

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

Direct Known Subclasses:None

class XBOXClientBeaconReceiver
extends IpDrv.UdpBeacon

    //=============================================================================
    // XBOXClientBeaconReceiver: Receives LAN beacons from servers.
    //=============================================================================

Variables
`struct` | `XBoxBeaconInfo`
`BYTE` | `m_CurrentNonce[4]`

Function Summary
`void` | `BeginPlay()`
`void` | `BroadcastBeacon(IpAddr Addr)`
`void` | `Destroyed()`
`string` | `GetBeaconAddress(int i)`
`string` | `GetBeaconText(int i)`
`string` | `GetXNADDR(int i)`
`string` | `GetXNKEY(int i)`
`string` | `GetXNKID(int i)`
`bool` | `QueryForHosts()`
`void` | `Timer()`

Source Code

    00001	//=============================================================================
    00002	// XBOXClientBeaconReceiver: Receives LAN beacons from servers.
    00003	//=============================================================================
    00004	class XBOXClientBeaconReceiver extends UdpBeacon
    00005		native
    00006		transient;
    00007
    00008	var BYTE m_CurrentNonce[4];
    00009
    00010	var struct XBoxBeaconInfo
    00011	{
    00012		var IpAddr      Addr;
    00013		var float       Time;
    00014		var string      ParamMenuAsText;
    00015		var string      xnaddrAsStr;
    00016		var string      xnkeyAsStr;
    00017		var string      xnkidAsStr;
    00018	} XBoxBeacons[7];
    00019
    00020	function string GetBeaconAddress( int i )
    00021	{
    00022		return XBoxBeacons[i].xnaddrAsStr; //IpAddrToString(XBoxBeacons[i].Addr);
    00023	}
    00024
    00025	function string GetBeaconText(int i)
    00026	{
    00027		return XBoxBeacons[i].ParamMenuAsText;
    00028	}
    00029
    00030	function string GetXNADDR( int i )
    00031	{
    00032		return XBoxBeacons[i].xnaddrAsStr;
    00033	}
    00034
    00035	function string GetXNKEY( int i )
    00036	{
    00037		return XBoxBeacons[i].xnkeyAsStr;
    00038	}
    00039
    00040	function string GetXNKID( int i )
    00041	{
    00042		return XBoxBeacons[i].xnkidAsStr;
    00043	}
    00044
    00045
    00046
    00047	native function bool QueryForHosts();
    00048	native function bool DecodeBuffer(IpAddr Addr, int Count, byte B[255], out string ParamMenuAsText, out string xnAddrAsText, out string xnkeyAsStr, out string xnkidAsStr );
    00049
    00050
    00051
    00052	event ReceivedBinary( IpAddr Addr, int Count, byte B[255] )
    00053	{
    00054		local int i, j;
    00055		local string ParamMenuAsText, xnaddrAsStr, xnkeyAsStr, xnkidAsStr;
    00056
    00057		DecodeBuffer(Addr, Count, B, ParamMenuAsText, xnaddrAsStr, xnkeyAsStr, xnkidAsStr);
    00058
    00059		for( i=0; i<arraycount(XBoxBeacons); i++ )
    00060			if( XBoxBeacons[i].xnaddrAsStr==xnaddrAsStr )
    00061				break;
    00062		if( i==arraycount(XBoxBeacons) )
    00063			for( i=0; i<arraycount(XBoxBeacons); i++ )
    00064				if( XBoxBeacons[i].xnaddrAsStr=="" )
    00065					break;
    00066		if( i==arraycount(XBoxBeacons) )
    00067			return;
    00068
    00069		XBoxBeacons[i].ParamMenuAsText = ParamMenuAsText;
    00070		XBoxBeacons[i].xnaddrAsStr     = xnaddrAsStr;
    00071		XBoxBeacons[i].xnkeyAsStr      = xnkeyAsStr;
    00072		XBoxBeacons[i].xnkidAsStr      = xnkidAsStr;
    00073		XBoxBeacons[i].Addr	           = Addr;
    00074		XBoxBeacons[i].Time            = Level.TimeSeconds;
    00075	}
    00076
    00077
    00078	function BeginPlay()
    00079	{
    00080		log("XBOXClientBeaconReceiver started !!!");
    00081		LinkMode = MODE_Binary;
    00082
    00083		if( BindPort( 1002, true ) > 0 )
    00084		{
    00085			SetTimer( 1.0, true );
    00086			log( "XBOXClientBeaconReceiver initialized." );
    00087		}
    00088		else
    00089		{
    00090			log( "XBOXClientBeaconReceiver failed: Beacon port in use." );
    00091		}
    00092	}
    00093
    00094	function Destroyed()
    00095	{
    00096		log( "ClientBeaconReceiver finished." );
    00097	}
    00098
    00099	function BroadcastBeacon(IpAddr Addr)
    00100	{
    00101		QueryForHosts();
    00102	}
    00103
    00104	function Timer()
    00105	{
    00106		local int i, j;
    00107	    local IpAddr Addr;
    00108
    00109		for( i=0; i<arraycount(XBoxBeacons); i++ )
    00110			if
    00111			(	XBoxBeacons[i].xnaddrAsStr!=""
    00112			&&	Level.TimeSeconds-XBoxBeacons[i].Time<BeaconTimeout )
    00113				XBoxBeacons[j++] = XBoxBeacons[i];
    00114		for( j=j; j<arraycount(XBoxBeacons); j++ )
    00115			XBoxBeacons[j].xnaddrAsStr="";
    00116
    00117		Addr.Addr = BroadcastAddr;		// useless
    00118		Addr.Port = ServerBeaconPort;	// useless
    00119
    00120		BroadcastBeacon(Addr);
    00121	}
    00122
    00123
    00124
    00125	defaultproperties
    00126	{
    00127	    ReceivedText=0
    00128	}

End Source Code