C# Class BF2Statistics.Gamespy.GpcmClient

Gamespy Client Manager This class is used to proccess the client login process, create new user accounts, and fetch profile information gpcm.gamespy.com
Inheritance: IDisposable
Show file Open project: BF2Statistics/ControlCenter Class Usage Examples

Public Properties

Property Type Description
ConnectionId int
Created System.DateTime

Protected Properties

Property Type Description
Crc BF2Statistics.Utilities.Crc16

Public Methods

Method Description
Disconnect ( int code ) : void

Logs the client out of the game client, and closes the stream

Codes: 0 => Client sends the "logout" command 1 => The login timer elapsed and the client wasnt logged in or this object was disposed, forcefully disconnected 2 => Invalid login query, or username was incorrect 3 => Incorrect Password 4 => An error occured while trying to login the client (could be database related) 5 => Cant create account, username exists already 6 => Error Creating new account in database 7 => Invalid query for account creation, or an exception was thrown while trying to create account 8 => Remote Connection closed the Stream or was un-readchable 9 => Forced server shutdown [No events called, database sessions are not updated, and EventArgs are disposed]

Dispose ( ) : void

Disposes of the client object. The connection is no longer closed here and the Disconnect even is NO LONGER fired

Equals ( object Obj ) : bool
GetHashCode ( ) : int
GpcmClient ( GamespyTcpStream ConnectionStream, int ConnectionId ) : System

Constructor

ProcessLogin ( string>.Dictionary Recv ) : void

This method verifies the login information sent by the client, and returns encrypted data for the client to verify as well

SendKeepAlive ( ) : void

Polls the connection, and checks for drops

SendServerChallenge ( ) : void

This method starts off by sending a random string 10 characters in length, known as the Server challenge key. This is used by the client to return a client challenge key, which is used to validate login information later.

Private Methods

Method Description
ConvertToKeyValue ( string parts ) : string>.Dictionary

Converts a recived parameter array from the client string to a keyValue pair dictionary

CreateNewUser ( string>.Dictionary Recv ) : void

Whenever the "newuser" command is recieved, this method is called to add the new users information into the database

GenerateProof ( string challenge1, string challenge2 ) : string

Generates an MD5 hash, which is used to verify the clients login information

GenerateRandomString ( int length ) : string

Generates a random alpha-numeric string

GenerateSig ( ) : string

Generates a random signature

SendProfile ( ) : void

This method is called when the client requests for the Account profile

Stream_DataReceived ( string message ) : void

Event called when a complete message has been recieved

Stream_OnDisconnect ( ) : void

Event fired when the stream disconnects. Even though its 1 line, we un-register it at one point, so it needs to be here

UpdateUser ( string>.Dictionary Recv ) : void

Updates the Users Country code when sent by the client

Method Details

Disconnect() public method

Logs the client out of the game client, and closes the stream
Codes: 0 => Client sends the "logout" command 1 => The login timer elapsed and the client wasnt logged in or this object was disposed, forcefully disconnected 2 => Invalid login query, or username was incorrect 3 => Incorrect Password 4 => An error occured while trying to login the client (could be database related) 5 => Cant create account, username exists already 6 => Error Creating new account in database 7 => Invalid query for account creation, or an exception was thrown while trying to create account 8 => Remote Connection closed the Stream or was un-readchable 9 => Forced server shutdown [No events called, database sessions are not updated, and EventArgs are disposed]
public Disconnect ( int code ) : void
code int /// The disconnect code. If set to 9, the OnDisconect event will not be called, the database /// will not be updated to reset everyone's session code, and the EventArgs objects will NOT /// be returned to the IO pool. You should only set to 9 for a planned server shutdown. ///
return void

Dispose() public method

Disposes of the client object. The connection is no longer closed here and the Disconnect even is NO LONGER fired
public Dispose ( ) : void
return void

Equals() public method

public Equals ( object Obj ) : bool
Obj object
return bool

GetHashCode() public method

public GetHashCode ( ) : int
return int

GpcmClient() public method

Constructor
public GpcmClient ( GamespyTcpStream ConnectionStream, int ConnectionId ) : System
ConnectionStream BF2Statistics.Gamespy.Net.GamespyTcpStream
ConnectionId int
return System

ProcessLogin() public method

This method verifies the login information sent by the client, and returns encrypted data for the client to verify as well
public ProcessLogin ( string>.Dictionary Recv ) : void
Recv string>.Dictionary
return void

SendKeepAlive() public method

Polls the connection, and checks for drops
public SendKeepAlive ( ) : void
return void

SendServerChallenge() public method

This method starts off by sending a random string 10 characters in length, known as the Server challenge key. This is used by the client to return a client challenge key, which is used to validate login information later.
public SendServerChallenge ( ) : void
return void

Property Details

ConnectionId public property

Indicates the connection ID for this connection
public int ConnectionId
return int

Crc protected static property

Our CRC16 object for generating Checksums
protected static Crc16,BF2Statistics.Utilities Crc
return BF2Statistics.Utilities.Crc16

Created public property

Indicates the date and time this connection was created
public DateTime,System Created
return System.DateTime