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

IpDrv.ServerVerify


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
//=============================================================================
// ServerVerify: Authentication for the game server.
//=============================================================================
class ServerVerify expands TcpLink;

// Waits for the Master Server to connect and send the code.  The code is then
// mangled by the encrypt function, and returned to the Master Server.  Once this
// occurs, this script becomes inactive.

var int         VerifyPort;         // Assumes this is set by the ServerUplink object
var string[32]  CodeString;         // Stores the code passed from master server
var string[240] RcvTemp;            // Buffer for recieving text
var int         InitialCode;
var int         ModifiedCode;
var int         AmtTrans;
var int         i,l;

auto state Listening
{
    function Tick( float DeltaTime )
    {
        if( Listen( VerifyPort ) )
        {
            // Operation successful, but did it connect?
            if( LinkState == TCP_Open )
            {
                // Connected, assume to Master Server
                GotoState('Recieving');
            }
        }
        else
        {
            // Some error occured.  Repeat anyway.
        }
    }

Begin:
    Enable( 'Tick' );
}

state Recieving
{
    function Tick( float DeltaTime )
    {
        // Expects to recieve exactly 10 characters
        AmtTrans  += ReadText( RcvTemp, 10-AmtTrans );
        CodeString = CodeString $ RcvTemp;
        if( AmtTrans >= 10 )
        {
            // The code was recieved.  Convert and send the 
            // corresponding response back.
            InitialCode  = Int    ( CodeString );
            ModifiedCode = Encrypt( InitialCode );
            CodeString   = String ( ModifiedCode );
            // Make sure that the string is exactly 10 characters long,
            // excluding the NULL.
            l = Len( CodeString );
            if( l < 9 )
            {
                // Pad it with space characters
                for( i=0; i<9-l; i++ )
                {
                    CodeString = CodeString $ " ";              
                }               
            }
            GotoState('Sending');
        }
    }

Begin:
    AmtTrans   = 0;
    CodeString = "";
}

state Sending
{
    function Tick( float DeltaTime )
    {
        // The Master Server expects exactly 10 characters
        AmtTrans += SendText( CodeString, AmtTrans );
        if( AmtTrans >= 10 )
        {
            // The code was fully sent.
            // Disconnect, set the timer, go to bed, wake up later and repeat.
            GotoState('WaitWhileClosing');
        }
    }

Begin:
    AmtTrans = 0;
}

state WaitWhileClosing
{
    function Timer()
    {
        Disable('Timer');
        Close();        
        Enable('Tick');
        GotoState('Listening');
    }

Begin:
    // This wait is necessary otherwise the close() command will
    // destroy the queued data that was sent.
    Disable('Tick');
    SetTimer(6,false);
}

state Inactive
{
Begin:
    Disable( 'Tick' );
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:52:32.000 - Creation time: za 22-4-2006 12:53:46.781 - Created with UnCodeX