Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

IpDrv.UdpBeacon


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
//=============================================================================
// UdpBeacon: Base class of beacon sender and receiver.
//=============================================================================
class UdpBeacon extends UdpLink
    config
    transient;

var() globalconfig bool       DoBeacon;
var() globalconfig int        ServerBeaconPort;     // Listen port
var() globalconfig int        BeaconPort;           // Reply port
var() globalconfig float      BeaconTimeout;
var() globalconfig string     BeaconProduct;

var int UdpServerQueryPort;

function BeginPlay()
{
    if( BindPort(ServerBeaconPort) )
    {
        log( "ServerBeacon listening on port "$ServerBeaconPort );
    }
    else
    {
        log( "ServerBeacon failed: Could not bind port "$ServerBeaconPort );
    }
    BroadcastBeacon(); // Initial notification.
}

function BroadcastBeacon()
{
    local IpAddr Addr;
    local string BeaconText;

    Log( "Broadcasting Beacon" );

    Addr.Addr = BroadcastAddr;
    Addr.Port = BeaconPort;
    BeaconText = Level.Game.GetBeaconText();
    SendText( Addr, BeaconProduct @ Mid(Level.GetAddressURL(),InStr(Level.GetAddressURL(),":")+1) @ BeaconText );
}


function BroadcastBeaconQuery()
{
    local IpAddr Addr;

    Log( "Broadcasting Query Beacon" );

    Addr.Addr = BroadcastAddr;
    Addr.Port = BeaconPort;

    SendText( Addr, BeaconProduct @ UdpServerQueryPort );
}


event ReceivedText( IpAddr Addr, string Text )
{
    if( Text == "REPORT" )
        BroadcastBeacon();

    if( Text == "REPORTQUERY" )
        BroadcastBeaconQuery();
}

function Destroyed()
{
    Super.Destroyed();
    Log("ServerBeacon Destroyed");
}

defaultproperties
{
     DoBeacon=True
     ServerBeaconPort=7775
     BeaconPort=7776
     BeaconTimeout=5.000000
     BeaconProduct="Unreal"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:48:02.000 - Creation time: za 22-4-2006 12:49:39.734 - Created with UnCodeX