TNLTest::TestConnection Class Reference
#include <testGame.h>
Inheritance diagram for TNLTest::TestConnection:
Detailed Description
TestConnection is the
TNLTest connection class.
The TestConnection class overrides particular methods for connection housekeeping, and for connected clients manages the transmission of client inputs to the server for player position updates.
When a client's connection to the server is lost, the TestConnection notifies the network interface that it should begin searching for a new server to join.
|
Public Types |
enum | RPCEnumerationValues { PlayerPosReplyBitSize = 6
} |
| Enumeration constant used to specify the size field of Float<> parameters in the rpcGotPlayerPos method. More...
|
Public Member Functions |
| TestConnection () |
| The TestConnection constructor.
|
void | onConnectTerminated (TNL::NetConnection::TerminationReason reason, const char *rejectionString) |
| onConnectTerminated is called when the connection request to the server is unable to complete due to server rejection, timeout or other error.
|
void | onConnectionTerminated (TNL::NetConnection::TerminationReason reason, const char *string) |
| onConnectionTerminated is called when an established connection is terminated, whether from the local or remote hosts explicitly disconnecting, timing out or network error.
|
void | onConnectionEstablished () |
| onConnectionEstablished is called on both ends of a connection when the connection is established.
|
bool | isDataToTransmit () |
| isDataToTransmit is called each time the connection is ready to send a packet.
|
| TNL_DECLARE_RPC (rpcSetPlayerPos,(TNL::F32 x, TNL::F32 y)) |
| Remote function that client calls to set the position of the player on the server.
|
| TNL_DECLARE_RPC (rpcGotPlayerPos,(bool b1, bool b2, TNL::StringTableEntry string, TNL::Float< PlayerPosReplyBitSize > x, TNL::Float< PlayerPosReplyBitSize > y)) |
| Remote function the server sends back to the client when it gets a player position.
|
| TNL_DECLARE_NETCONNECTION (TestConnection) |
| TNL_DECLARE_NETCONNECTION is used to declare that TestConnection is a valid connection class to the TNL network system.
|
Data Fields |
TNL::SafePtr< Player > | myPlayer |
| The player object associated with this connection.
|
Private Types |
typedef TNL::GhostConnection | Parent |
Member Typedef Documentation
Member Enumeration Documentation
|
Enumeration constant used to specify the size field of Float<> parameters in the rpcGotPlayerPos method.
- Enumeration values:
-
PlayerPosReplyBitSize |
Size, in bits of the floats the server sends to the client to acknowledge position updates. |
|
Constructor & Destructor Documentation
TNLTest::TestConnection::TestConnection |
( |
|
) |
|
|
|
The TestConnection constructor.
This method contains a line that can be uncommented to put the TestConnection into adaptive communications mode. |
Member Function Documentation
|
onConnectTerminated is called when the connection request to the server is unable to complete due to server rejection, timeout or other error.
When a TestConnection connect request to a server is terminated, the client's network interface is notified so it can begin searching for another server to connect to. |
|
onConnectionTerminated is called when an established connection is terminated, whether from the local or remote hosts explicitly disconnecting, timing out or network error.
When a TestConnection to a server is disconnected, the client's network interface is notified so it can begin searching for another server to connect to. |
void TNLTest::TestConnection::onConnectionEstablished |
( |
|
) |
[virtual] |
|
|
onConnectionEstablished is called on both ends of a connection when the connection is established.
On the server this will create a player for this client, and set it as the client's scope object. On both sides this will set the proper ghosting behavior for the connection (ie server to client).
Reimplemented from TNL::NetConnection. |
bool TNLTest::TestConnection::isDataToTransmit |
( |
|
) |
[virtual] |
|
|
isDataToTransmit is called each time the connection is ready to send a packet.
If the NetConnection subclass has data to send it should return true. In the case of a simulation, this should always return true.
Reimplemented from TNL::GhostConnection. |
TNLTest::TestConnection::TNL_DECLARE_RPC |
( |
rpcSetPlayerPos |
, |
|
|
(TNL::F32 x, TNL::F32 y) |
|
|
) |
|
|
|
Remote function that client calls to set the position of the player on the server.
|
|
Remote function the server sends back to the client when it gets a player position.
We only use 6 bits of precision on each float to illustrate the float compression that's possible using TNL's RPC. This RPC also sends bool and StringTableEntry data, as well as showing the use of the TNL_DECLARE_RPC_ENUM macro. |
|
TNL_DECLARE_NETCONNECTION is used to declare that TestConnection is a valid connection class to the TNL network system.
|
Field Documentation
|
The player object associated with this connection.
|