#include <CustomPacket.h>
Inheritance diagram for GNE::CustomPacket:
Public Types | |
typedef SmartPtr< CustomPacket > | sptr |
typedef WeakPtr< CustomPacket > | wptr |
Public Member Functions | |
CustomPacket (const CustomPacket &o) | |
Buffer & | getBuffer () |
Returns the Buffer for reading or writing. | |
void | clear () |
If you want to reuse a CustomPacket after using it for reading or writing, you should call clear which will reset this object as if it were newly constructed with the default constructor. | |
virtual int | getSize () const |
virtual void | writePacket (Buffer &raw) const |
Writes a CustomPacket to the given Buffer. | |
virtual void | readPacket (Buffer &raw) |
Reads a CustomPacket from the given Buffer. | |
Static Public Member Functions | |
int | getMaxUserDataSize () |
Returns the capacity of Buffers created by CustomPacket made for writing. | |
Static Public Attributes | |
const int | ID = 1 |
The ID for this type of packet. |
The maximum amount of data that can be stored in the CustomPacket is defined by its Buffer's capacity, which at the current time is 3 bytes smaller than Buffer::RAW_PACKET_LEN.
See the documentation for Packet for more info on some of these functions.
|
Returns the Buffer for reading or writing. You should not keep the returned reference longer than the packet's destruction, or a reset or readPacket call. When writing data to the buffer, do not call "flip" after writing data. The position should be left at the point after your last write call. After a CustomPacket has been read, and you are pulling data out of it, the position and the limit will be the number of bytes stored in this CustomPacket. You need to call rewind or flip (at this point, both are equivalent) on the buffer before pulling data from it, or a buffer overflow exception will result. |
|
Reimplemented from GNE::Packet. |
|
Reads a CustomPacket from the given Buffer. The data in this packet will be erased and replaced by the new data. Then flip is called on the Buffer, so position is 0 and the bytes this CustomPacket contains is the Buffer's limit. Reimplemented from GNE::Packet. |
|
Writes a CustomPacket to the given Buffer. Flip will be called on the Buffer then it will be written to the passed Buffer, so the final result will be an unchanged position, but limit == position. Reimplemented from GNE::Packet. |