#include <src/network/packet/Packet.h>
Public Member Functions | |
int | getClientID () |
virtual unsigned char * | getData () |
uint32_t | getFlags () |
virtual unsigned int | getSize () const =0 |
Packet (const Packet &p) | |
virtual bool | process ()=0 |
bool | send () |
void | setClientID (int id) |
virtual | ~Packet () |
Destroys a packet completely. | |
Static Public Member Functions | |
static Packet * | createPacket (ENetPacket *packet, ENetPeer *peer) |
static void | deletePacket (ENetPacket *packet) |
ENet calls this method whenever it wants to destroy a packet that contains data we allocated ourselves. | |
Protected Member Functions | |
bool | isDataENetAllocated () const |
Packet (uint8_t *data, unsigned int clientID) | |
Packet () | |
Protected Attributes | |
bool | bDataENetAllocated_ |
unsigned int | clientID_ |
uint8_t * | data_ |
uint32_t | flags_ |
Direction::Value | packetDirection_ |
Private Attributes | |
ENetPacket * | enetPacket_ |
Static Private Attributes | |
static std::map< size_t, Packet * > | packetMap_ |
orxonox::packet::Packet::Packet | ( | const Packet & | p | ) |
References bDataENetAllocated_, clientID_, data_, enetPacket_, flags_, getSize(), and packetDirection_.
orxonox::packet::Packet::~Packet | ( | ) | [virtual] |
Destroys a packet completely.
That also means destroying the ENetPacket if one exists. There
References bDataENetAllocated_, data_, and enetPacket_.
orxonox::packet::Packet::Packet | ( | ) | [protected] |
orxonox::packet::Packet::Packet | ( | uint8_t * | data, | |
unsigned int | clientID | |||
) | [protected] |
Packet * orxonox::packet::Packet::createPacket | ( | ENetPacket * | packet, | |
ENetPeer * | peer | |||
) | [static] |
References _PACKETID, orxonox::packet::Type::Acknowledgement, bDataENetAllocated_, orxonox::packet::Type::Chat, orxonox::packet::Type::ClassID, COUT, orxonox::packet::Type::DeleteObjects, enetPacket_, orxonox::ClientInformation::findClient(), orxonox::packet::Type::FunctionCalls, orxonox::packet::Type::FunctionIDs, orxonox::packet::Type::Gamestate, orxonox::ClientInformation::getID(), orxonox::Host::isServer(), and orxonox::packet::Type::Welcome.
Referenced by orxonox::Server::processPacket(), and orxonox::Connection::processPacket().
void orxonox::packet::Packet::deletePacket | ( | ENetPacket * | packet | ) | [static] |
ENet calls this method whenever it wants to destroy a packet that contains data we allocated ourselves.
References COUT, and packetMap_.
Referenced by send().
int orxonox::packet::Packet::getClientID | ( | ) | [inline] |
virtual unsigned char* orxonox::packet::Packet::getData | ( | ) | [inline, virtual] |
uint32_t orxonox::packet::Packet::getFlags | ( | ) | [inline] |
Referenced by send().
virtual unsigned int orxonox::packet::Packet::getSize | ( | ) | const [pure virtual] |
bool orxonox::packet::Packet::isDataENetAllocated | ( | ) | const [inline, protected] |
virtual bool orxonox::packet::Packet::process | ( | ) | [pure virtual] |
Implemented in orxonox::packet::Acknowledgement, orxonox::packet::Chat, orxonox::packet::ClassID, orxonox::packet::DeleteObjects, orxonox::packet::FunctionCalls, orxonox::packet::FunctionIDs, orxonox::packet::Gamestate, and orxonox::packet::Welcome.
Referenced by orxonox::Server::processPacket(), and orxonox::Connection::processPacket().
bool orxonox::packet::Packet::send | ( | ) |
References _PACKETID, orxonox::packet::Type::Acknowledgement, orxonox::Host::addPacket(), orxonox::packet::Direction::Bidirectional, orxonox::packet::Type::Chat, orxonox::packet::Type::ClassID, clientID_, data_, orxonox::packet::Type::DeleteObjects, deletePacket(), enetPacket_, orxonox::packet::Type::FunctionCalls, orxonox::packet::Type::FunctionIDs, orxonox::packet::Type::Gamestate, getData(), getFlags(), getSize(), orxonox::packet::Direction::Outgoing, packetDirection_, packetMap_, and orxonox::packet::Type::Welcome.
Referenced by orxonox::Client::chat(), orxonox::Server::createClient(), orxonox::Server::processChat(), orxonox::GamestateClient::sendAck(), orxonox::Server::sendChat(), orxonox::Server::sendObjectDeletes(), orxonox::Server::syncClassid(), and orxonox::Client::update().
void orxonox::packet::Packet::setClientID | ( | int | id | ) | [inline] |
bool orxonox::packet::Packet::bDataENetAllocated_ [protected] |
Tells whether data_ was allocated by ENet or ourselves. data_ might no correlate with enetPacket_->data.
Referenced by createPacket(), orxonox::packet::Gamestate::decompressData(), Packet(), and ~Packet().
unsigned int orxonox::packet::Packet::clientID_ [protected] |
Reimplemented in orxonox::packet::Chat, and orxonox::packet::FunctionCalls.
Referenced by orxonox::packet::Acknowledgement::Acknowledgement(), Packet(), orxonox::packet::Acknowledgement::process(), and send().
uint8_t* orxonox::packet::Packet::data_ [protected] |
Pointer to the data. Be careful when deleting it because it might point to a location that was allocated by ENet. See bDataENetAllocated_
Referenced by orxonox::packet::Acknowledgement::Acknowledgement(), orxonox::packet::FunctionCalls::addCallMember(), orxonox::packet::FunctionCalls::addCallStatic(), orxonox::packet::Chat::Chat(), orxonox::packet::ClassID::ClassID(), orxonox::packet::Gamestate::collectData(), orxonox::packet::Gamestate::compressData(), orxonox::packet::Gamestate::decompressData(), orxonox::packet::Gamestate::diff(), orxonox::packet::Gamestate::doSelection(), orxonox::packet::DeleteObjects::fetchIDs(), orxonox::packet::FunctionCalls::FunctionCalls(), orxonox::packet::FunctionIDs::FunctionIDs(), orxonox::packet::Gamestate::Gamestate(), orxonox::packet::Acknowledgement::getAckID(), orxonox::packet::Welcome::getData(), orxonox::packet::Chat::getMessage(), orxonox::packet::Gamestate::getSize(), orxonox::packet::FunctionIDs::getSize(), orxonox::packet::DeleteObjects::getSize(), orxonox::packet::ClassID::getSize(), orxonox::packet::Gamestate::operator==(), Packet(), orxonox::packet::Welcome::process(), orxonox::packet::FunctionIDs::process(), orxonox::packet::FunctionCalls::process(), orxonox::packet::DeleteObjects::process(), orxonox::packet::ClassID::process(), orxonox::packet::Chat::process(), send(), orxonox::packet::Gamestate::spreadData(), orxonox::packet::Gamestate::undiff(), orxonox::packet::Welcome::Welcome(), and ~Packet().
ENetPacket* orxonox::packet::Packet::enetPacket_ [private] |
Referenced by createPacket(), Packet(), send(), and ~Packet().
uint32_t orxonox::packet::Packet::flags_ [protected] |
Referenced by orxonox::packet::Acknowledgement::Acknowledgement(), orxonox::packet::Chat::Chat(), orxonox::packet::ClassID::ClassID(), orxonox::packet::DeleteObjects::DeleteObjects(), orxonox::packet::Gamestate::diff(), orxonox::packet::FunctionCalls::FunctionCalls(), orxonox::packet::FunctionIDs::FunctionIDs(), orxonox::packet::Gamestate::Gamestate(), Packet(), orxonox::packet::Gamestate::undiff(), and orxonox::packet::Welcome::Welcome().
Referenced by orxonox::packet::Gamestate::diff(), Packet(), send(), and orxonox::packet::Gamestate::undiff().
std::map< size_t, Packet * > orxonox::packet::Packet::packetMap_ [static, private] |
Referenced by deletePacket(), and send().