NetInterface
Engine/source/sim/netInterface.h
NetInterface class.
Connection management
Most of these are pretty self-explanatory.
addPendingConnection(NetConnection * conn)
findPendingConnection(const NetAddress * address, U32 packetSequence)
removePendingConnection(NetConnection * conn)
handleConnectChallengeRequest(const NetAddress * addr, BitStream * stream)
handleConnectChallengeResponse(const NetAddress * address, BitStream * stream)
sendConnectRequest(NetConnection * conn)
handleConnectRequest(const NetAddress * address, BitStream * stream)
sendConnectAccept(NetConnection * conn)
handleConnectAccept(const NetAddress * address, BitStream * stream)
sendConnectReject(NetConnection * conn, const char * reason)
handleConnectReject(const NetAddress * address, BitStream * stream)
handleDisconnect(const NetAddress * address, BitStream * stream)
Public Types
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 }
PacketType is encoded as the first byte of each packet.
Protected Types
NetInterfaceConstants { MaxPendingConnects = 20 ChallengeRetryCount = 4 ChallengeRetryTime = 2500 ConnectRetryCount = 4 ConnectRetryTime = 2500 TimeoutCheckInterval = 1500 }
Protected Attributes
bool
Is this NetInterface allowing connections at this time?
Last time all the active connections were checked for timeouts.
Vector< NetConnection * >
List of connections that are in the startup phase.
bool
Have we initialized our random number generator?
mRandomHashData [12]
Data that gets hashed with connect challenge requests to prevent connection spoofing.
Protected Functions
computeNetMD5(const NetAddress * address, U32 connectSequence, U32 addressDigest)
Calculate an MD5 sum representing a connection, and store it into addressDigest.
Initialize random data.
Public Functions
Checks for timeouts on all valid and pending connections.
bool
Returns whether or not this NetInterface allows connections from remote hosts.
handleInfoPacket(const NetAddress * address, U8 packetType, BitStream * stream)
Handles all packets that don't fall into the category of connection handshake or game data.
Checks all connections marked as client to server for packet sends.
processPacketReceiveEvent(NetAddress srcAddress, RawData packetData)
Dispatch function for processing all network packets through this NetInterface.
Checks all connections marked as server to client for packet sends.
sendDisconnectPacket(NetConnection * conn, const char * reason)
Send a disconnect packet on a connection, along with a reason.
setAllowsConnections(bool conn)
Sets whether or not this NetInterface allows connections from remote hosts.
startConnection(NetConnection * conn)
Begins the connection handshaking process for a connection.
Detailed Description
NetInterface class.
Manages all valid and pending notify protocol connections.
Connection management
Most of these are pretty self-explanatory.
addPendingConnection(NetConnection * conn)
findPendingConnection(const NetAddress * address, U32 packetSequence)
removePendingConnection(NetConnection * conn)
sendConnectChallengeRequest(NetConnection * conn)
handleConnectChallengeRequest(const NetAddress * addr, BitStream * stream)
handleConnectChallengeResponse(const NetAddress * address, BitStream * stream)
sendConnectRequest(NetConnection * conn)
handleConnectRequest(const NetAddress * address, BitStream * stream)
sendConnectAccept(NetConnection * conn)
handleConnectAccept(const NetAddress * address, BitStream * stream)
sendConnectReject(NetConnection * conn, const char * reason)
handleConnectReject(const NetAddress * address, BitStream * stream)
handleDisconnect(const NetAddress * address, BitStream * stream)
Public Types
PacketTypes
Enumerator
- 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
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.
Protected Types
NetInterfaceConstants
Enumerator
- MaxPendingConnects = 20
Maximum number of pending connections. If new connection requests come in before.
- ChallengeRetryCount = 4
Number of times to send connect challenge requests before giving up.
- ChallengeRetryTime = 2500
Timeout interval in milliseconds before retrying connect challenge.
- ConnectRetryCount = 4
Number of times to send connect requests before giving up.
- ConnectRetryTime = 2500
Timeout interval in milliseconds before retrying connect request.
- TimeoutCheckInterval = 1500
Interval in milliseconds between checking for connection timeouts.
Protected Attributes
bool mAllowConnections
Is this NetInterface allowing connections at this time?
U32 mLastTimeoutCheckTime
Last time all the active connections were checked for timeouts.
Vector< NetConnection * > mPendingConnections
List of connections that are in the startup phase.
bool mRandomDataInitialized
Have we initialized our random number generator?
U32 mRandomHashData [12]
Data that gets hashed with connect challenge requests to prevent connection spoofing.
Protected Functions
computeNetMD5(const NetAddress * address, U32 connectSequence, U32 addressDigest)
Calculate an MD5 sum representing a connection, and store it into addressDigest.
initRandomData()
Initialize random data.
Public Functions
NetInterface()
checkTimeouts()
Checks for timeouts on all valid and pending connections.
doesAllowConnections()
Returns whether or not this NetInterface allows connections from remote hosts.
handleInfoPacket(const NetAddress * address, U8 packetType, BitStream * stream)
Handles all packets that don't fall into the category of connection handshake or game data.
Reimplemented by: DemoNetInterface
processClient()
Checks all connections marked as client to server for packet sends.
processPacketReceiveEvent(NetAddress srcAddress, RawData packetData)
Dispatch function for processing all network packets through this NetInterface.
processServer()
Checks all connections marked as server to client for packet sends.
sendDisconnectPacket(NetConnection * conn, const char * reason)
Send a disconnect packet on a connection, along with a reason.
setAllowsConnections(bool conn)
Sets whether or not this NetInterface allows connections from remote hosts.
startConnection(NetConnection * conn)
Begins the connection handshaking process for a connection.