dtNetGM::NetworkComponent Class Reference

baseclass GMComponent to communicate as client - server More...

#include <networkcomponent.h>

Inheritance diagram for dtNetGM::NetworkComponent:

dtGame::GMComponent dtCore::Base dtNetGM::ClientNetworkComponent dtNetGM::ServerNetworkComponent

List of all members.

Public Member Functions

 NetworkComponent (const std::string &gameName, const int gameVersion, const std::string &logFile="")
 Construct a NetworkComponent with a game name and version to be used by GNE Calls InitializeNetwork to initialize GNE.
virtual void OnAddedToGM ()
 Called immediately after a component is added to the GM.
virtual void ProcessMessage (const dtGame::Message &message)
 Function called by a GameManager to process Messages.
virtual void ProcessNetClientRequestConnection (const MachineInfoMessage &msg)
 Processes a MessageType::NETCLIENT_REQUEST_CONNECTION Message.
virtual void ProcessNetServerAcceptConnection (const MachineInfoMessage &msg)
 Processes a MessageType::NETSERVER_ACCEPT_CONNECTION Message.
virtual void ProcessNetServerRejectConnection (const dtGame::NetServerRejectMessage &msg)
 Processes a MessageType::NETSERVER_REJECT_CONNECTION Message.
virtual void ProcessInfoClientConnected (const MachineInfoMessage &msg)
 Processes a MessageType::INFO_CLIENT_CONNECTED Message.
virtual void ProcessNetClientNotifyDisconnect (const MachineInfoMessage &msg)
 Processes a MessageType::NETCLIENT_NOTIFY_DISCONNECT Message.
virtual void ProcessNetServerRejectMessage (const dtGame::ServerMessageRejected &msg)
 Processes a MessageType::SERVER_REQUEST_REJECTED Message.
void SetConnectionParameters (bool reliable=true, int bandWidthIn=0, int bandWidthOut=0)
 Sets the connection Parameters to be used by GNE.
virtual void OnNewConnection (NetworkBridge &networkBridge)
 Function called by a NetworkBridge if a new connection is received.
virtual void OnConnect (NetworkBridge &networkBridge)
 Function called by a NetworkBridge if a new connection is made.
virtual void OnExit (NetworkBridge &networkBridge)
 Function called by a NetworkBridge if a connection exits.
virtual void OnDisconnect (NetworkBridge &networkBridge)
 Function called by a NetworkBridge if a connection disconnects.
virtual void OnFailure (NetworkBridge &networkBridge, const GNE::Error &error)
 Function called by a NetworkBridge if a failure occurs.
virtual void OnError (NetworkBridge &networkBridge, const GNE::Error &error)
 Function called by a NetworkBridge if an error occurs.
virtual void OnConnectFailure (NetworkBridge &networkBridge, const GNE::Error &error)
 Function called by a NetworkBridge if a connection failure occurs.
virtual void OnTimeOut (NetworkBridge &networkBridge)
 Function called by a NetworkBridge if a timeout occurs.
virtual void DispatchNetworkMessage (const dtGame::Message &message)
 Function called by a GameManager to send Messages accross a Network.
virtual void OnReceivedDataStream (NetworkBridge &networkBridge, dtUtil::DataStream &dataStream)
 Function called by a Networkbridge to Signal a received DataStream The network component creates the message and checks for destination and / or connection info contained in the message.
virtual void OnReceivedNetworkMessage (const dtGame::Message &message, NetworkBridge &networkBridge)
void SendNetworkMessage (const dtGame::Message &message, const DestinationType &destinationType=DestinationType::DESTINATION)
dtUtil::DataStream CreateDataStream (const dtGame::Message &message)
dtCore::RefPtr< dtGame::MessageCreateMessage (dtUtil::DataStream &dataStream, const NetworkBridge &networkBridge)
const bool & IsReliable () const
 Is our GNE connection reliable.
const bool & IsGneInitialized () const
 Is GNE already initialized.
virtual const bool IsServer () const
 Is this NetworkComponent a server?
void GetConnectedClients (std::vector< NetworkBridge * > &connectedClients)
 Retrieves a vector containing all NetworkBridge which have an accepted client connection.
virtual void ShutdownNetwork ()
 Shutdown network communications and clear connections.
bool IsShuttingDown ()
 Are we shutting down?

Protected Member Functions

virtual ~NetworkComponent (void)
void AddConnection (NetworkBridge *networkBridge)
 Adds a NetworkBridge to the map.
void RemoveConnection (const dtGame::MachineInfo &machineInfo)
 Removes a NetworkBridge from the map.
NetworkBridgeGetConnection (const dtGame::MachineInfo &machineInfo)
 Retrieves a NetworkBridge from the map If no networkbridge is found, NULL is returned.
virtual const dtGame::MachineInfoGetMachineInfo (const dtCore::UniqueId &uniqueId)
 Retrieves a dtGame::MachineInfo* from the stored connections If no matching connection is found, NULL is returned.

Protected Attributes

std::vector< NetworkBridge * > mConnections
bool mReliable
int mRateOut
int mRateIn
GNE::Mutex mMutex

Classes

class  DestinationType
 enumeration class to address different stored connections More...


Detailed Description

baseclass GMComponent to communicate as client - server

Constructor & Destructor Documentation

dtNetGM::NetworkComponent::NetworkComponent ( const std::string &  gameName,
const int  gameVersion,
const std::string &  logFile = "" 
)

Construct a NetworkComponent with a game name and version to be used by GNE Calls InitializeNetwork to initialize GNE.

Parameters:
gameName The game name
gameVersion The game version
logFile The logfile name

dtNetGM::NetworkComponent::~NetworkComponent ( void   )  [protected, virtual]


Member Function Documentation

void dtNetGM::NetworkComponent::OnAddedToGM (  )  [virtual]

Called immediately after a component is added to the GM.

Used to register 'additional' Network Messages on the GameManager

Reimplemented from dtGame::GMComponent.

void dtNetGM::NetworkComponent::ProcessMessage ( const dtGame::Message message  )  [virtual]

Function called by a GameManager to process Messages.

This function forwards the connection related messages to the functions processing these messages.

Parameters:
The Message to be process

Reimplemented from dtGame::GMComponent.

virtual void dtNetGM::NetworkComponent::ProcessNetClientRequestConnection ( const MachineInfoMessage msg  )  [inline, virtual]

Processes a MessageType::NETCLIENT_REQUEST_CONNECTION Message.

Parameters:
msg The message

Reimplemented in dtNetGM::ServerNetworkComponent.

virtual void dtNetGM::NetworkComponent::ProcessNetServerAcceptConnection ( const MachineInfoMessage msg  )  [inline, virtual]

Processes a MessageType::NETSERVER_ACCEPT_CONNECTION Message.

Parameters:
msg The message

Reimplemented in dtNetGM::ClientNetworkComponent.

virtual void dtNetGM::NetworkComponent::ProcessNetServerRejectConnection ( const dtGame::NetServerRejectMessage msg  )  [inline, virtual]

Processes a MessageType::NETSERVER_REJECT_CONNECTION Message.

Parameters:
msg The message

Reimplemented in dtNetGM::ClientNetworkComponent.

virtual void dtNetGM::NetworkComponent::ProcessInfoClientConnected ( const MachineInfoMessage msg  )  [inline, virtual]

Processes a MessageType::INFO_CLIENT_CONNECTED Message.

Parameters:
msg The message

Reimplemented in dtNetGM::ClientNetworkComponent.

virtual void dtNetGM::NetworkComponent::ProcessNetClientNotifyDisconnect ( const MachineInfoMessage msg  )  [inline, virtual]

Processes a MessageType::NETCLIENT_NOTIFY_DISCONNECT Message.

Parameters:
msg The message

Reimplemented in dtNetGM::ClientNetworkComponent.

virtual void dtNetGM::NetworkComponent::ProcessNetServerRejectMessage ( const dtGame::ServerMessageRejected msg  )  [inline, virtual]

Processes a MessageType::SERVER_REQUEST_REJECTED Message.

Parameters:
msg The message

Reimplemented in dtNetGM::ClientNetworkComponent.

void dtNetGM::NetworkComponent::SetConnectionParameters ( bool  reliable = true,
int  bandWidthIn = 0,
int  bandWidthOut = 0 
)

Sets the connection Parameters to be used by GNE.

Parameters:
reliable The reliability of the connection
bandWidthIn The incoming bandwidth throttle
bandWidthOut The outgoing bandwidth throttle

void dtNetGM::NetworkComponent::OnNewConnection ( NetworkBridge networkBridge  )  [virtual]

Function called by a NetworkBridge if a new connection is received.

Parameters:
The NetworkBridge

void dtNetGM::NetworkComponent::OnConnect ( NetworkBridge networkBridge  )  [virtual]

Function called by a NetworkBridge if a new connection is made.

Parameters:
The NetworkBridge

void dtNetGM::NetworkComponent::OnExit ( NetworkBridge networkBridge  )  [virtual]

Function called by a NetworkBridge if a connection exits.

Parameters:
The NetworkBridge

void dtNetGM::NetworkComponent::OnDisconnect ( NetworkBridge networkBridge  )  [virtual]

Function called by a NetworkBridge if a connection disconnects.

Parameters:
The NetworkBridge

Reimplemented in dtNetGM::ClientNetworkComponent, and dtNetGM::ServerNetworkComponent.

void dtNetGM::NetworkComponent::OnFailure ( NetworkBridge networkBridge,
const GNE::Error &  error 
) [virtual]

Function called by a NetworkBridge if a failure occurs.

Parameters:
networkBridge The NetworkBridge
error The GNE::Error description

void dtNetGM::NetworkComponent::OnError ( NetworkBridge networkBridge,
const GNE::Error &  error 
) [virtual]

Function called by a NetworkBridge if an error occurs.

Parameters:
networkBridge The NetworkBridge
error The GNE::Error description

void dtNetGM::NetworkComponent::OnConnectFailure ( NetworkBridge networkBridge,
const GNE::Error &  error 
) [virtual]

Function called by a NetworkBridge if a connection failure occurs.

Parameters:
networkBridge The NetworkBridge
error The GNE::Error description

void dtNetGM::NetworkComponent::OnTimeOut ( NetworkBridge networkBridge  )  [virtual]

Function called by a NetworkBridge if a timeout occurs.

Parameters:
networkBridge The NetworkBridge

void dtNetGM::NetworkComponent::DispatchNetworkMessage ( const dtGame::Message message  )  [virtual]

Function called by a GameManager to send Messages accross a Network.

Parameters:
The Message to be sent

Reimplemented from dtGame::GMComponent.

void dtNetGM::NetworkComponent::OnReceivedDataStream ( NetworkBridge networkBridge,
dtUtil::DataStream dataStream 
) [virtual]

Function called by a Networkbridge to Signal a received DataStream The network component creates the message and checks for destination and / or connection info contained in the message.

If appropriate, the message is delivered to the GameManager

Parameters:
networkBridge The NetworkBridge which received the MessagePakcet
dataStream The DataStream received

void dtNetGM::NetworkComponent::OnReceivedNetworkMessage ( const dtGame::Message message,
NetworkBridge networkBridge 
) [virtual]

void dtNetGM::NetworkComponent::SendNetworkMessage ( const dtGame::Message message,
const DestinationType destinationType = DestinationType::DESTINATION 
)

dtUtil::DataStream dtNetGM::NetworkComponent::CreateDataStream ( const dtGame::Message message  ) 

dtCore::RefPtr< dtGame::Message > dtNetGM::NetworkComponent::CreateMessage ( dtUtil::DataStream dataStream,
const NetworkBridge networkBridge 
)

const bool& dtNetGM::NetworkComponent::IsReliable (  )  const [inline]

Is our GNE connection reliable.

Returns:
The reliability of the connection

const bool& dtNetGM::NetworkComponent::IsGneInitialized (  )  const [inline]

Is GNE already initialized.

Returns:
GNE initialization

virtual const bool dtNetGM::NetworkComponent::IsServer (  )  const [inline, virtual]

Is this NetworkComponent a server?

Returns:
server true/false

void dtNetGM::NetworkComponent::GetConnectedClients ( std::vector< NetworkBridge * > &  connectedClients  ) 

Retrieves a vector containing all NetworkBridge which have an accepted client connection.

Parameters:
The vector to be filled

void dtNetGM::NetworkComponent::ShutdownNetwork (  )  [virtual]

Shutdown network communications and clear connections.

bool dtNetGM::NetworkComponent::IsShuttingDown (  )  [inline]

Are we shutting down?

Returns:
ShuttingDown

void dtNetGM::NetworkComponent::AddConnection ( NetworkBridge networkBridge  )  [protected]

Adds a NetworkBridge to the map.

Parameters:
The networkbridge

void dtNetGM::NetworkComponent::RemoveConnection ( const dtGame::MachineInfo machineInfo  )  [protected]

Removes a NetworkBridge from the map.

Parameters:
The MachineInfo of the connection to be removed

NetworkBridge * dtNetGM::NetworkComponent::GetConnection ( const dtGame::MachineInfo machineInfo  )  [protected]

Retrieves a NetworkBridge from the map If no networkbridge is found, NULL is returned.

Parameters:
The machineinfo
Returns:
Pointer to the networkbridge

const dtGame::MachineInfo * dtNetGM::NetworkComponent::GetMachineInfo ( const dtCore::UniqueId uniqueId  )  [protected, virtual]

Retrieves a dtGame::MachineInfo* from the stored connections If no matching connection is found, NULL is returned.

Parameters:
dtCore::UniqueId of the MachineInfo
Returns:
Pointer to the dtGame::MachineInfo* or NULL

Reimplemented in dtNetGM::ClientNetworkComponent.


Member Data Documentation

std::vector<NetworkBridge*> dtNetGM::NetworkComponent::mConnections [protected]

bool dtNetGM::NetworkComponent::mReliable [protected]

int dtNetGM::NetworkComponent::mRateOut [protected]

int dtNetGM::NetworkComponent::mRateIn [protected]

GNE::Mutex dtNetGM::NetworkComponent::mMutex [protected]


http://www.delta3d.org
2.0.0 generated 14 Feb 2008