Torque2D Reference
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
NetInterface Class Reference

#include <netInterface.h>

+ Inheritance diagram for NetInterface:

Public Types

enum  PacketTypes {
  MasterServerGameTypesRequest = 2 , MasterServerGameTypesResponse = 4 , MasterServerListRequest = 6 , MasterServerListResponse = 8 ,
  GameMasterInfoRequest = 10 , GameMasterInfoResponse = 12 , GamePingRequest = 14 , GamePingResponse = 16 ,
  GameInfoRequest = 18 , GameInfoResponse = 20 , GameHeartbeat = 22 , GGCPacket = 24 ,
  ConnectChallengeRequest = 26 , ConnectChallengeReject = 28 , ConnectChallengeResponse = 30 , ConnectRequest = 32 ,
  ConnectReject = 34 , ConnectAccept = 36 , Disconnect = 38 , MasterServerExtendedListResponse = 40 ,
  MasterServerChallenge = 42 , MasterServerExtendedListRequest = 44
}
 

Public Member Functions

 NetInterface ()
 
void removePendingConnection (NetConnection *conn)
 
bool doesAllowConnections ()
 Returns whether or not this NetInterface allows connections from remote hosts.
 
void setAllowsConnections (bool conn)
 Sets whether or not this NetInterface allows connections from remote hosts.
 
virtual void processPacketReceiveEvent (PacketReceiveEvent *event)
 Dispatch function for processing all network packets through this NetInterface.
 
virtual void handleInfoPacket (const NetAddress *address, U8 packetType, BitStream *stream)
 Handles all packets that don't fall into the category of connection handshake or game data.
 
void processClient ()
 Checks all connections marked as client to server for packet sends.
 
void processServer ()
 Checks all connections marked as server to client for packet sends.
 
void startConnection (NetConnection *conn)
 Begins the connection handshaking process for a connection.
 
void checkTimeouts ()
 Checks for timeouts on all valid and pending connections.
 
void sendDisconnectPacket (NetConnection *conn, const char *reason)
 Send a disconnect packet on a connection, along with a reason.
 

Protected Types

enum  NetInterfaceConstants {
  MaxPendingConnects = 20 , ChallengeRetryCount = 4 , ChallengeRetryTime = 2500 , ConnectRetryCount = 4 ,
  ConnectRetryTime = 2500 , TimeoutCheckInterval = 1500
}
 

Protected Member Functions

void initRandomData ()
 Initialize random data.
 
void computeNetMD5 (const NetAddress *address, U32 connectSequence, U32 addressDigest[4])
 Calculate an MD5 sum representing a connection, and store it into addressDigest.
 
Connection management

Most of these are pretty self-explanatory.

void addPendingConnection (NetConnection *conn)
 
NetConnectionfindPendingConnection (const NetAddress *address, U32 packetSequence)
 
void sendConnectChallengeRequest (NetConnection *conn)
 
void handleConnectChallengeRequest (const NetAddress *addr, BitStream *stream)
 
void handleConnectChallengeResponse (const NetAddress *address, BitStream *stream)
 
void sendConnectRequest (NetConnection *conn)
 
void handleConnectRequest (const NetAddress *address, BitStream *stream)
 
void sendConnectAccept (NetConnection *conn)
 
void handleConnectAccept (const NetAddress *address, BitStream *stream)
 
void sendConnectReject (NetConnection *conn, const char *reason)
 
void handleConnectReject (const NetAddress *address, BitStream *stream)
 
void handleDisconnect (const NetAddress *address, BitStream *stream)
 

Protected Attributes

Vector< NetConnection * > mPendingConnections
 List of connections that are in the startup phase.
 
U32 mLastTimeoutCheckTime
 Last time all the active connections were checked for timeouts.
 
U32 mRandomHashData [12]
 Data that gets hashed with connect challenge requests to prevent connection spoofing.
 
bool mRandomDataInitialized
 Have we initialized our random number generator?
 
bool mAllowConnections
 Is this NetInterface allowing connections at this time?
 

Detailed Description

NetInterface class. Manages all valid and pending notify protocol connections.

See also
NetConnection, GameConnection, NetObject, NetEvent

Member Enumeration Documentation

◆ NetInterfaceConstants

enum NetInterfaceConstants
protected
Enumerator
MaxPendingConnects 

Maximum number of pending connections. If new connection requests come in before.

ChallengeRetryCount 

Number of times to send connect challenge requests before giving up.

ChallengeRetryTime 

Timeout interval in milliseconds before retrying connect challenge.

ConnectRetryCount 

Number of times to send connect requests before giving up.

ConnectRetryTime 

Timeout interval in milliseconds before retrying connect request.

TimeoutCheckInterval 

Interval in milliseconds between checking for connection timeouts.

◆ PacketTypes

PacketType is encoded as the first byte of each packet. If the LSB of the first byte is set (i.e. if the type number is odd), then the packet is a data protocol packet, otherwise it's an OOB packet, suitable for use in strange protocols, like game querying or connection initialization.

Enumerator
MasterServerGameTypesRequest 
MasterServerGameTypesResponse 
MasterServerListRequest 
MasterServerListResponse 
GameMasterInfoRequest 
GameMasterInfoResponse 
GamePingRequest 
GamePingResponse 
GameInfoRequest 
GameInfoResponse 
GameHeartbeat 
GGCPacket 
ConnectChallengeRequest 
ConnectChallengeReject 
ConnectChallengeResponse 
ConnectRequest 
ConnectReject 
ConnectAccept 
Disconnect 
MasterServerExtendedListResponse 
MasterServerChallenge 
MasterServerExtendedListRequest 

Constructor & Destructor Documentation

◆ NetInterface()

Member Function Documentation

◆ addPendingConnection()

void addPendingConnection ( NetConnection conn)
protected

◆ checkTimeouts()

void checkTimeouts ( )

Checks for timeouts on all valid and pending connections.

◆ computeNetMD5()

void computeNetMD5 ( const NetAddress address,
U32  connectSequence,
U32  addressDigest[4] 
)
protected

Calculate an MD5 sum representing a connection, and store it into addressDigest.

◆ doesAllowConnections()

bool doesAllowConnections ( )
inline

Returns whether or not this NetInterface allows connections from remote hosts.

◆ findPendingConnection()

NetConnection * findPendingConnection ( const NetAddress address,
U32  packetSequence 
)
protected

◆ handleConnectAccept()

void handleConnectAccept ( const NetAddress address,
BitStream stream 
)
protected

◆ handleConnectChallengeRequest()

void handleConnectChallengeRequest ( const NetAddress addr,
BitStream stream 
)
protected

◆ handleConnectChallengeResponse()

void handleConnectChallengeResponse ( const NetAddress address,
BitStream stream 
)
protected

◆ handleConnectReject()

void handleConnectReject ( const NetAddress address,
BitStream stream 
)
protected

◆ handleConnectRequest()

void handleConnectRequest ( const NetAddress address,
BitStream stream 
)
protected

◆ handleDisconnect()

void handleDisconnect ( const NetAddress address,
BitStream stream 
)
protected

◆ handleInfoPacket()

void handleInfoPacket ( const NetAddress address,
U8  packetType,
BitStream stream 
)
virtual

Handles all packets that don't fall into the category of connection handshake or game data.

Reimplemented in DemoNetInterface.

◆ initRandomData()

void initRandomData ( )
protected

Initialize random data.

◆ processClient()

void processClient ( )

Checks all connections marked as client to server for packet sends.

◆ processPacketReceiveEvent()

void processPacketReceiveEvent ( PacketReceiveEvent event)
virtual

Dispatch function for processing all network packets through this NetInterface.

◆ processServer()

void processServer ( )

Checks all connections marked as server to client for packet sends.

◆ removePendingConnection()

void removePendingConnection ( NetConnection conn)

◆ sendConnectAccept()

void sendConnectAccept ( NetConnection conn)
protected

◆ sendConnectChallengeRequest()

void sendConnectChallengeRequest ( NetConnection conn)
protected

◆ sendConnectReject()

void sendConnectReject ( NetConnection conn,
const char *  reason 
)
protected

◆ sendConnectRequest()

void sendConnectRequest ( NetConnection conn)
protected

◆ sendDisconnectPacket()

void sendDisconnectPacket ( NetConnection conn,
const char *  reason 
)

Send a disconnect packet on a connection, along with a reason.

◆ setAllowsConnections()

void setAllowsConnections ( bool  conn)
inline

Sets whether or not this NetInterface allows connections from remote hosts.

◆ startConnection()

void startConnection ( NetConnection conn)

Begins the connection handshaking process for a connection.

Member Data Documentation

◆ mAllowConnections

bool mAllowConnections
protected

Is this NetInterface allowing connections at this time?

◆ mLastTimeoutCheckTime

U32 mLastTimeoutCheckTime
protected

Last time all the active connections were checked for timeouts.

◆ mPendingConnections

Vector<NetConnection *> mPendingConnections
protected

List of connections that are in the startup phase.

◆ mRandomDataInitialized

bool mRandomDataInitialized
protected

Have we initialized our random number generator?

◆ mRandomHashData

U32 mRandomHashData[12]
protected

Data that gets hashed with connect challenge requests to prevent connection spoofing.


The documentation for this class was generated from the following files: