Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::Client Class Reference

Client *client; The network/Client class This class implements all necessary function for the network communication It is the root class of the network module. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/network/Client.h>

Inheritance diagram for orxonox::Client:
orxonox::Host orxonox::ClientConnection orxonox::Singleton< Client > orxonox::GamestateManager orxonox::Connection orxonox::GamestateHandler

Public Member Functions

 Client ()
 Constructor for the Client class initializes the address and the port to default localhost:NETWORK_PORT. More...
 
 ~Client ()
 
virtual bool closeConnection () override
 closes the Connection to the Server More...
 
virtual void doReceiveChat (const std::string &message, unsigned int sourceID, unsigned int targetID) override
 Gets called if a packet::Chat packet is received. More...
 
virtual void doSendChat (const std::string &message, unsigned int sourceID, unsigned int targetID) override
 Sends a chat message to the server. More...
 
virtual bool establishConnection () override
 Establish the Connection to the Server. More...
 
virtual void printRTT () override
 
virtual void queuePacket (ENetPacket *packet, int clientID, uint8_t channelID) override
 
virtual bool sendPacket (packet::Packet *packet) override
 
void setDestination (const std::string &serverAddress, unsigned int port)
 
void update (const Clock &time)
 Processes incoming packets, sends a gamestate to the server and does the cleanup. More...
 
- Public Member Functions inherited from orxonox::Host
bool isActive ()
 
- Public Member Functions inherited from orxonox::GamestateManager
 GamestateManager ()
 
 ~GamestateManager ()
 
virtual bool ackGamestate (unsigned int gamestateID, unsigned int peerID) override
 Acknowledge a received gamestate. More...
 
virtual bool addGamestate (packet::Gamestate *gs, unsigned int peerID) override
 
void addPeer (uint32_t peerID)
 Add a peer to the game. More...
 
void finishGamestate (unsigned int peerID, packet::Gamestate *&destgamestate, packet::Gamestate *base, packet::Gamestate *gamestate)
 
virtual uint32_t getCurrentGamestateID () override
 
std::vector< packet::Gamestate * > getGamestates ()
 Return a vector with the gamestates of all peers. More...
 
virtual uint32_t getLastReceivedGamestateID (unsigned int peerID) override
 Return the ID of the last received gamestate for a certain peer. More...
 
bool getSnapshot ()
 Update the current gamestate. More...
 
bool hasPeers ()
 
bool processGamestates ()
 Process the queued gamestates. More...
 
void removePeer (uint32_t peerID)
 Remove a peer from the game. More...
 
bool sendAck (unsigned int gamestateID, uint32_t peerID)
 Send Acknowledgement packet. More...
 
void setSynched (uint32_t peerID)
 
bool update ()
 

Static Public Member Functions

static ClientgetInstance ()
 
- Static Public Member Functions inherited from orxonox::Host
static void addPacket (ENetPacket *packet, int clientID=NETWORK_PEER_ID_SERVER, uint8_t channelID=0)
 This function is used to add an enetpacket to be sent to another peer. More...
 
static HostgetActiveInstance ()
 Singleton implementation. More...
 
static unsigned int getPlayerID ()
 
static bool isServer ()
 
static bool running ()
 
static void sendChat (const std::string &message, unsigned int sourceID, unsigned int targetID)
 Sends a chat message through the network. More...
 
static void setClientID (unsigned int id)
 
- Static Public Member Functions inherited from orxonox::Singleton< Client >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static ClientgetInstance ()
 Returns a reference to the singleton instance. More...
 

Protected Member Functions

virtual void connectionClosed () override
 
- Protected Member Functions inherited from orxonox::Host
 Host ()
 Constructor: assures that only one reference will be created and sets the pointer. More...
 
virtual ~Host ()
 Destructor: resets the instance pointer to nullptr. More...
 
void setActive (bool bActive)
 
- Protected Member Functions inherited from orxonox::GamestateHandler
 GamestateHandler ()
 
virtual ~GamestateHandler ()
 
- Protected Member Functions inherited from orxonox::ClientConnection
uint32_t getRTT ()
 
 ClientConnection ()
 
virtual ~ClientConnection ()
 
void addPacket (ENetPacket *packet, uint8_t channelID)
 
bool isConnected ()
 
void setPort (unsigned int port)
 
void setServerAddress (const std::string &serverAddress)
 
- Protected Member Functions inherited from orxonox::Connection
 Connection (uint32_t firstPeerID=NETWORK_PEER_ID_SERVER+1)
 Constructor. More...
 
void addPacket (ENetPacket *packet, uint32_t peerID, uint8_t channelID)
 Send a packet. More...
 
void broadcastPacket (ENetPacket *packet, uint8_t channelID)
 Send a broadcast packet. More...
 
void disconnectPeer (uint32_t peerID)
 Send an outgoing event of type 'disconnectPeer'. More...
 
void disconnectPeers ()
 Send an outgoing event of type 'disconnectPeers'. More...
 
void disconnectPeersInternal ()
 
void enableCompression ()
 
incomingEvent preprocessConnectEvent (ENetEvent &event)
 
incomingEvent preprocessDisconnectEvent (ENetEvent &event)
 
incomingEvent preprocessReceiveEvent (ENetEvent &event)
 
void processIncomingEvent (ENetEvent &event)
 Handle an incoming event. More...
 
void processOutgoingEvent (outgoingEvent &event)
 Send an event. More...
 
void processQueue ()
 
void startCommunicationThread ()
 Start the main communication thread. More...
 
void stopCommunicationThread ()
 Stop the main communication thread. More...
 
void waitOutgoingQueue ()
 
virtual ~Connection ()
 Destructor. More...
 
- Protected Member Functions inherited from orxonox::Singleton< Client >
 Singleton ()
 Constructor sets the singleton instance pointer. More...
 
virtual ~Singleton ()
 Destructor resets the singleton instance pointer. More...
 

Private Member Functions

 Client (const Client &copy)
 
virtual bool isServer_ () override
 
virtual void processPacket (packet::Packet *packet) override
 

Private Attributes

bool gameStateFailure_
 
bool isSynched_
 
std::deque< packet::Packet * > packetQueue_
 
float timeSinceLastUpdate_
 

Static Private Attributes

static ClientsingletonPtr_s
 

Friends

class Singleton< Client >
 

Additional Inherited Members

- Static Protected Member Functions inherited from orxonox::Singleton< Client >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static ClientgetInstance ()
 Returns a reference to the singleton instance. More...
 
- Protected Attributes inherited from orxonox::Connection
ENetHosthost_
 

Detailed Description

Client *client; The network/Client class This class implements all necessary function for the network communication It is the root class of the network module.

Constructor & Destructor Documentation

orxonox::Client::Client ( )

Constructor for the Client class initializes the address and the port to default localhost:NETWORK_PORT.

orxonox::Client::~Client ( )
orxonox::Client::Client ( const Client copy)
private

Member Function Documentation

bool orxonox::Client::closeConnection ( )
overridevirtual

closes the Connection to the Server

Returns
true/false

Reimplemented from orxonox::ClientConnection.

void orxonox::Client::connectionClosed ( )
overrideprotectedvirtual
void orxonox::Client::doReceiveChat ( const std::string &  message,
unsigned int  sourceID,
unsigned int  targetID 
)
overridevirtual

Gets called if a packet::Chat packet is received.

Calls the parent function which passes the message to the listeners.

Implements orxonox::Host.

void orxonox::Client::doSendChat ( const std::string &  message,
unsigned int  sourceID,
unsigned int  targetID 
)
overridevirtual

Sends a chat message to the server.

Parameters
messagemessage to be sent
sourceIDthe ID of the sender
targetIDthe ID of the receiver

Implements orxonox::Host.

bool orxonox::Client::establishConnection ( )
overridevirtual

Establish the Connection to the Server.

Returns
true/false

Reimplemented from orxonox::ClientConnection.

static Client* orxonox::Client::getInstance ( )
inlinestatic
virtual bool orxonox::Client::isServer_ ( )
inlineoverrideprivatevirtual

Implements orxonox::Host.

void orxonox::Client::printRTT ( )
overridevirtual

Implements orxonox::Host.

void orxonox::Client::processPacket ( packet::Packet packet)
overrideprivatevirtual

Implements orxonox::Connection.

void orxonox::Client::queuePacket ( ENetPacket packet,
int  clientID,
uint8_t  channelID 
)
overridevirtual

Implements orxonox::Host.

virtual bool orxonox::Client::sendPacket ( packet::Packet packet)
inlineoverridevirtual
void orxonox::Client::setDestination ( const std::string &  serverAddress,
unsigned int  port 
)
void orxonox::Client::update ( const Clock time)

Processes incoming packets, sends a gamestate to the server and does the cleanup.

Parameters
time

Friends And Related Function Documentation

friend class Singleton< Client >
friend

Member Data Documentation

bool orxonox::Client::gameStateFailure_
private
bool orxonox::Client::isSynched_
private
std::deque<packet::Packet*> orxonox::Client::packetQueue_
private
Client* orxonox::Client::singletonPtr_s
staticprivate
float orxonox::Client::timeSinceLastUpdate_
private

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