#include <ChannelPacket.h>
Inheritance diagram for GNE::ChannelPacket:
Public Member Functions | |
ChannelPacket () | |
Default constructor for the create function. | |
ChannelPacket (int channel, int from, const Packet &packet) | |
Inits a new ChannelPacket for the given channel, and from the given source ID. | |
int | getChannel () const |
Returns the channel this packet is meant to be sent to, or came in from, depending on the context. | |
void | setChannel (int chan) |
Sets the channel this Packet is meant for. | |
int | getSource () const |
Returns the source ID for this packet. | |
void | setSource (int source) |
Sets the source ID for this packet. | |
virtual Packet * | makeClone () const |
Returns a newly allocated exact copy of this packet. | |
virtual int | getSize () const |
Returns the current size of this packet in bytes. | |
virtual void | writePacket (Buffer &raw) const |
Writes the packet to the given Buffer. | |
virtual void | readPacket (Buffer &raw) |
Reads this packet from the given Buffer. | |
Static Public Member Functions | |
static Packet * | create () |
Returns a new instance of this class suitable only to call readPacket on. | |
Static Public Attributes | |
static const int | ID = 5 |
The ID for this type of packet. |
This is a packet type meant to be used with the high-level API, and provides routing information for the Server class.
GNE::ChannelPacket::ChannelPacket | ( | ) |
Default constructor for the create function.
The constructed ChannelPacket is valid only for a readPacket call. You must use the constructor with parameters to create a ChannelPacket for sending.
GNE::ChannelPacket::ChannelPacket | ( | int | channel, | |
int | from, | |||
const Packet & | packet | |||
) |
Inits a new ChannelPacket for the given channel, and from the given source ID.
A copy of the passed packet is made and stored inside the ChannelPacket. This copy is made using the Packet::makeClone method.
int GNE::ChannelPacket::getSource | ( | ) | const |
Returns the source ID for this packet.
A source ID of 0 is commonly considered to be "unknown."
void GNE::ChannelPacket::setChannel | ( | int | chan | ) |
Sets the channel this Packet is meant for.
If the channel number given is out of range, this method has no effect, but in the debugging version of the library, an assert will be triggered.
chan | the channel number in the range of [0..255] |
void GNE::ChannelPacket::setSource | ( | int | source | ) |
Sets the source ID for this packet.
source | the source ID in the range [0..255] |