GNE::ChannelPacket Class Reference
[High-Level API]

A ChannelPacket wraps around a normal Packet to give that Packet a channel destination and information about its source. More...

#include <ChannelPacket.h>

Inheritance diagram for GNE::ChannelPacket:

Inheritance graph
[legend]
Collaboration diagram for GNE::ChannelPacket:

Collaboration graph
[legend]
List of all members.

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 PacketmakeClone () 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 Packetcreate ()
 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.

Detailed Description

A ChannelPacket wraps around a normal Packet to give that Packet a channel destination and information about its source.

This is a packet type meant to be used with the high-level API, and provides routing information for the Server class.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
chan the channel number in the range of [0..255]

void GNE::ChannelPacket::setSource ( int  source  ) 

Sets the source ID for this packet.

Parameters:
source the source ID in the range [0..255]


The documentation for this class was generated from the following files:
Generated on Tue Sep 5 23:47:45 2006 for GNE by  doxygen 1.4.7