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::Host Class Referenceabstract

Base class of Server and Client This is the Base class of the Server and Client classes. More...

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

Inheritance diagram for orxonox::Host:
orxonox::GamestateManager orxonox::GamestateHandler orxonox::Client orxonox::Server

Public Member Functions

bool isActive ()
 
virtual void printRTT ()=0
 
- 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 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)
 

Protected Member Functions

 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...
 
virtual void doReceiveChat (const std::string &message, unsigned int sourceID, unsigned int targetID)=0
 Gets called if a packet::Chat packet is received. More...
 
virtual void doSendChat (const std::string &message, unsigned int sourceID, unsigned int targetID)=0
 
void setActive (bool bActive)
 
- Protected Member Functions inherited from orxonox::GamestateManager
virtual bool sendPacket (packet::Packet *packet)=0
 
- Protected Member Functions inherited from orxonox::GamestateHandler
 GamestateHandler ()
 
virtual ~GamestateHandler ()
 

Private Member Functions

virtual bool isServer_ ()=0
 
virtual void queuePacket (ENetPacket *packet, int clientID, uint8_t channelID)=0
 

Private Attributes

bool bIsActive_
 

Static Private Attributes

static uint32_t clientID_s = 0
 
static std::vector< Host * > instances_s
 

Friends

class packet::Chat
 

Detailed Description

Base class of Server and Client This is the Base class of the Server and Client classes.

Constructor & Destructor Documentation

orxonox::Host::Host ( )
protected

Constructor: assures that only one reference will be created and sets the pointer.

orxonox::Host::~Host ( )
protectedvirtual

Destructor: resets the instance pointer to nullptr.

Member Function Documentation

void orxonox::Host::addPacket ( ENetPacket packet,
int  clientID = NETWORK_PEER_ID_SERVER,
uint8_t  channelID = 0 
)
static

This function is used to add an enetpacket to be sent to another peer.

Parameters
packetPacket to be added
clientIDID of the client the packet should be sent to
channelIDID of the channel.
Returns
success?
void orxonox::Host::doReceiveChat ( const std::string &  message,
unsigned int  sourceID,
unsigned int  targetID 
)
protectedpure virtual

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

Passes the message to the listeners.

Implemented in orxonox::Server, and orxonox::Client.

virtual void orxonox::Host::doSendChat ( const std::string &  message,
unsigned int  sourceID,
unsigned int  targetID 
)
protectedpure virtual

Implemented in orxonox::Server, and orxonox::Client.

Host * orxonox::Host::getActiveInstance ( )
static

Singleton implementation.

Return the first active instance.

static unsigned int orxonox::Host::getPlayerID ( )
inlinestatic
bool orxonox::Host::isActive ( void  )
inline
bool orxonox::Host::isServer ( )
static
virtual bool orxonox::Host::isServer_ ( )
privatepure virtual

Implemented in orxonox::Client, and orxonox::Server.

virtual void orxonox::Host::printRTT ( )
pure virtual

Implemented in orxonox::Client, and orxonox::Server.

virtual void orxonox::Host::queuePacket ( ENetPacket packet,
int  clientID,
uint8_t  channelID 
)
privatepure virtual

Implemented in orxonox::Client, and orxonox::Server.

static bool orxonox::Host::running ( )
inlinestatic
void orxonox::Host::sendChat ( const std::string &  message,
unsigned int  sourceID,
unsigned int  targetID 
)
static

Sends a chat message through the network.

Parameters
messagemessage to be sent
sourceIDthe ID of the sender
targetIDthe ID of the receiver
void orxonox::Host::setActive ( bool  bActive)
inlineprotected
static void orxonox::Host::setClientID ( unsigned int  id)
inlinestatic

Friends And Related Function Documentation

friend class packet::Chat
friend

Member Data Documentation

bool orxonox::Host::bIsActive_
private
uint32_t orxonox::Host::clientID_s = 0
staticprivate
std::vector< Host * > orxonox::Host::instances_s
staticprivate

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