Orxonox: orxonox::Host Class Reference

# orxonox::Host Class Reference

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

- Makes server and client a singleton
- defines static functions available on both server and client
- is the interface to be used when communicating with the network.

More...

`#include <src/network/Host.h>`

Inheritance diagram for orxonox::Host:

List of all members.

## Static Public Member Functions

static bool | addPacket (ENetPacket *packet, int clientID=0)
static bool | Broadcast (const std::string &message)
static bool | Chat (const std::string &message)
static unsigned int | getPlayerID ()
static unsigned int | getShipID ()
static bool | incomingChat (const std::string &message, unsigned int playerID)
static bool | isServer ()
static bool | running ()
static void | setClientID (unsigned int id)
static void | setShipID (unsigned int id)

## Protected Member Functions

| Host ()
| Constructor: assures that only one reference will be created and sets the pointer.
virtual | ~Host ()
| Destructor: resets the instance pointer to 0.

## Protected Attributes

unsigned int | clientID_
unsigned int | shipID_

## Static Protected Attributes

static Host * | instance_ = 0

## Private Member Functions

virtual bool | broadcast (const std::string &message)=0
virtual bool | chat (const std::string &message)=0
virtual bool | isServer_ ()=0
virtual bool | processChat (const std::string &message, unsigned int playerID)=0
virtual bool | queuePacket (ENetPacket *packet, int clientID)=0

## Detailed Description

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

- Makes server and client a singleton
- defines static functions available on both server and client
- is the interface to be used when communicating with the network.

Author:
  Oliver Scheuss

## Constructor & Destructor Documentation

orxonox::Host::Host | ( |  | ) | `[protected]`

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

References clientID_, and instance_.

orxonox::Host::~Host | ( |  | ) | `[protected, virtual]`

Destructor: resets the instance pointer to 0.

References instance_.

## Member Function Documentation

bool orxonox::Host::addPacket | ( | ENetPacket * | packet,
|  | int | clientID = `0` |
| ) |  |  | `[static]`

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

Parameters:

  | packet | Packet to be added
  | clientID | ID of the client the packet should be sent to

Returns:
  success?

References instance_, and queuePacket().

Referenced by orxonox::packet::Packet::send().

bool orxonox::Host::Broadcast | ( | const std::string & | message | ) | `[static]`

References broadcast(), orxonox::CLIENTID_UNKNOWN, and instance_.

Referenced by orxonox::UnderAttack::destroyedPawn(), orxonox::Deathmatch::end(), orxonox::Asteroids::end(), orxonox::Deathmatch::pawnKilled(), orxonox::Deathmatch::playerChangedName(), orxonox::Deathmatch::playerEntered(), orxonox::Deathmatch::playerLeft(), orxonox::Deathmatch::playerScored(), orxonox::Deathmatch::start(), orxonox::Asteroids::start(), and orxonox::UnderAttack::tick().

virtual bool orxonox::Host::broadcast | ( | const std::string & | message | ) | `[private, pure virtual]`

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

Referenced by Broadcast().

bool orxonox::Host::Chat | ( | const std::string & | message | ) | `[static]`

References chat(), and instance_.

virtual bool orxonox::Host::chat | ( | const std::string & | message | ) | `[private, pure virtual]`

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

Referenced by Chat().

unsigned int orxonox::Host::getPlayerID | ( |  | ) | `[static]`

This function returns the ID of the player

Returns:
  playerID

References clientID_, and instance_.

Referenced by orxonox::Server::chat(), orxonox::Client::chat(), and orxonox::HumanPlayer::networkcallback_clientIDchanged().

static unsigned int orxonox::Host::getShipID | ( |  | ) | `[inline, static]`

bool orxonox::Host::incomingChat | ( | const std::string & | message,
|  | unsigned int | playerID |
| ) |  |  | `[static]`

References instance_, and processChat().

Referenced by orxonox::packet::Chat::process().

static bool orxonox::Host::isServer | ( |  | ) | `[inline, static]`

Referenced by orxonox::packet::Packet::createPacket(), orxonox::Synchronisable::Synchronisable(), and orxonox::Synchronisable::~Synchronisable().

virtual bool orxonox::Host::isServer_ | ( |  | ) | `[private, pure virtual]`

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

virtual bool orxonox::Host::processChat | ( | const std::string & | message,
|  | unsigned int | playerID |
| ) |  |  | `[private, pure virtual]`

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

Referenced by incomingChat().

virtual bool orxonox::Host::queuePacket | ( | ENetPacket * | packet,
|  | int | clientID |
| ) |  |  | `[private, pure virtual]`

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

Referenced by addPacket().

static bool orxonox::Host::running | ( |  | ) | `[inline, static]`

Referenced by orxonox::Synchronisable::Synchronisable(), and orxonox::Synchronisable::~Synchronisable().

static void orxonox::Host::setClientID | ( | unsigned int | id | ) | `[inline, static]`

Referenced by orxonox::packet::Welcome::process().

static void orxonox::Host::setShipID | ( | unsigned int | id | ) | `[inline, static]`

## Member Data Documentation

unsigned int orxonox::Host::clientID_`[protected]`

Referenced by getPlayerID(), and Host().

Host * orxonox::Host::instance_ = 0`[static, protected]`

Referenced by addPacket(), Broadcast(), Chat(), getPlayerID(), Host(), incomingChat(), and ~Host().

unsigned int orxonox::Host::shipID_`[protected]`

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

- src/network/Host.h
- src/network/Host.cc