Main Page Modules Namespaces C++ Classes Compound List File List Index
TNLTest::TestNetInterface class Reference

TNLTest::TestNetInterface Class Reference

#include <testGame.h>

Inheritance diagram for TNLTest::TestNetInterface:

TNL::NetInterface TNL::Object

Detailed Description

TestNetInterface - the NetInterface subclass used in TNLTest.

TestNetInterface subclasses TNLTest to provide server pinging and response info packets. When a client TestNetInterface starts, it begins sending ping packets to the pingAddr address specified in the constructor. When a server receives a GamePingRequest packet, it sends a GamePingResponse packet to the source address of the GamePingRequest. Upon receipt of this response packet, the client attempts to connect to the server that returned the response. When the connection or connection attempt to that server is terminated, the TestNetInterface resumes pinging for available TNLTest servers.


Public Types

enum  Constants {
  PingDelayTime = 2000,
  GamePingRequest = FirstValidInfoPacketId,
  GamePingResponse
}
 Constants used in this NetInterface. More...


Public Member Functions

 TestNetInterface (TestGame *theGame, bool server, const TNL::Address &bindAddress, const TNL::Address &pingAddr)
 Constructor for this network interface, called from the constructor for TestGame.

void handleInfoPacket (const TNL::Address &address, TNL::U8 packetType, TNL::BitStream *stream)
 handleInfoPacket overrides the method in the NetInterface class to handle processing of the GamePingRequest and GamePingResponse packet types.

void sendPing ()
 sendPing sends a GamePingRequest packet to pingAddress of this TestNetInterface.

void tick ()
 Tick checks to see if it is an appropriate time to send a ping packet, in addition to checking for incoming packets and processing connections.


Data Fields

bool pingingServers
 True if this is a client that is pinging for active servers.

TNL::U32 lastPingTime
 The last platform time that a GamePingRequest was sent from this network interface.

bool isServer
 True if this network interface is a server, false if it is a client.

TNL::SafePtr< TestConnectionconnectionToServer
 A safe pointer to the current connection to the server, if this is a client.

TNL::Address pingAddress
 Network address to ping in searching for a server. This can be a specific host address or it can be a LAN broadcast address.

TestGamegame
 The game object associated with this network interface.


Private Types

typedef TNL::NetInterface Parent


Member Typedef Documentation

typedef TNL::NetInterface TNLTest::TestNetInterface::Parent [private]
 


Member Enumeration Documentation

enum TNLTest::TestNetInterface::Constants
 

Constants used in this NetInterface.

Enumeration values:
PingDelayTime  Milliseconds to wait between sending GamePingRequest packets.
GamePingRequest  Byte value of the first byte of a GamePingRequest packet.
GamePingResponse  Byte value of the first byte of a GamePingResponse packet.


Constructor & Destructor Documentation

TNLTest::TestNetInterface::TestNetInterface TestGame theGame,
bool  server,
const TNL::Address bindAddress,
const TNL::Address pingAddr
 

Constructor for this network interface, called from the constructor for TestGame.

The constructor initializes and binds the network interface, as well as sets parameters for the associated game and whether or not it is a server.


Member Function Documentation

void TNLTest::TestNetInterface::handleInfoPacket const TNL::Address address,
TNL::U8  packetType,
TNL::BitStream stream
 

handleInfoPacket overrides the method in the NetInterface class to handle processing of the GamePingRequest and GamePingResponse packet types.

void TNLTest::TestNetInterface::sendPing  ) 
 

sendPing sends a GamePingRequest packet to pingAddress of this TestNetInterface.

void TNLTest::TestNetInterface::tick  ) 
 

Tick checks to see if it is an appropriate time to send a ping packet, in addition to checking for incoming packets and processing connections.


Field Documentation

bool TNLTest::TestNetInterface::pingingServers
 

True if this is a client that is pinging for active servers.

TNL::U32 TNLTest::TestNetInterface::lastPingTime
 

The last platform time that a GamePingRequest was sent from this network interface.

bool TNLTest::TestNetInterface::isServer
 

True if this network interface is a server, false if it is a client.

TNL::SafePtr<TestConnection> TNLTest::TestNetInterface::connectionToServer
 

A safe pointer to the current connection to the server, if this is a client.

TNL::Address TNLTest::TestNetInterface::pingAddress
 

Network address to ping in searching for a server. This can be a specific host address or it can be a LAN broadcast address.

TestGame* TNLTest::TestNetInterface::game
 

The game object associated with this network interface.