diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-07-25 18:04:38 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2006-07-25 18:04:38 +0000 |
commit | c7e7b62aa94bf295ca1dc556762ad6070221e0cd (patch) | |
tree | 04f827df0df64a80e04a4115986609486d715237 /src/net/messageout.h | |
parent | c0c8775271679ac4904bc0bc02a74d28fc75efd0 (diff) | |
download | mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.tar.gz mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.tar.bz2 mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.tar.xz mana-c7e7b62aa94bf295ca1dc556762ad6070221e0cd.zip |
Switched client to use enet and modified login sequence to work with the new protocol from tmwserv.
Diffstat (limited to 'src/net/messageout.h')
-rw-r--r-- | src/net/messageout.h | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/src/net/messageout.h b/src/net/messageout.h index f6468adb..8431d887 100644 --- a/src/net/messageout.h +++ b/src/net/messageout.h @@ -1,5 +1,5 @@ /* - * The Mana World + * The Mana World Server * Copyright 2004 The Mana World Development Team * * This file is part of The Mana World. @@ -21,32 +21,30 @@ * $Id$ */ -#ifndef _TMW_MESSAGEOUT_ -#define _TMW_MESSAGEOUT_ +#ifndef _TMWSERV_MESSAGEOUT_H_ +#define _TMWSERV_MESSAGEOUT_H_ #include <iosfwd> -#include <SDL_types.h> - -class Network; /** * Used for building an outgoing message. */ class MessageOut { - friend MessageOut& operator<<(MessageOut &msg, const Sint8 &rhs); - friend MessageOut& operator<<(MessageOut &msg, const Sint16 &rhs); - friend MessageOut& operator<<(MessageOut &msg, const Sint32 &rhs); - public: /** * Constructor. */ - MessageOut(Network *network); + MessageOut(); - void writeInt8(Sint8 value); /**< Writes a byte. */ - void writeInt16(Sint16 value); /**< Writes a short. */ - void writeInt32(Sint32 value); /**< Writes a long. */ + /** + * Destructor. + */ + ~MessageOut(); + + void writeByte(char value); /**< Writes a byte. */ + void writeShort(short value); /**< Writes a short. */ + void writeLong(long value); /**< Writes a long. */ /** * Writes a string. If a fixed length is not given (-1), it is stored @@ -54,8 +52,25 @@ class MessageOut */ void writeString(const std::string &string, int length = -1); + /** + * Returns the content of the message. + */ + char *getData(); + + /** + * Returns the length of the data. + */ + unsigned int getDataSize(); + private: - Network *mNetwork; + /** + * Expand the packet data to be able to hold more data. + * + * NOTE: For performance enhancements this method could allocate extra + * memory in advance instead of expanding size every time more data is + * added. + */ + void expand(size_t size); char *mData; /**< Data building up. */ unsigned int mDataSize; /**< Size of data. */ |