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/network.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/network.h')
-rw-r--r-- | src/net/network.h | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/net/network.h b/src/net/network.h index f4637f73..50ee9af7 100644 --- a/src/net/network.h +++ b/src/net/network.h @@ -25,19 +25,22 @@ #define _TMW_NETWORK_ #include <map> -#include <SDL_net.h> -#include <SDL_thread.h> +#include <queue> #include <string> +#include <guichan.hpp> + +#include <enet/enet.h> + class MessageHandler; class MessageIn; +class MessageOut; class Network; class Network { public: - friend int networkThread(void *data); friend class MessageOut; Network(); @@ -53,46 +56,39 @@ class Network int getState() const { return mState; } bool isConnected() const { return mState == CONNECTED; } - int getInSize() const { return mInSize; } - - void skip(int len); - - bool messageReady(); - MessageIn getNextMessage(); - void dispatchMessages(); void flush(); - enum { + void send(MessageOut *msg); + + enum State { IDLE, CONNECTED, CONNECTING, DATA, - ERROR + NET_ERROR }; + ENetHost *mClient; + ENetPeer *mServer; + protected: - Uint16 readWord(int pos); - TCPsocket mSocket; std::string mAddress; short mPort; - char *mInBuffer, *mOutBuffer; - unsigned int mInSize, mOutSize; - unsigned int mToSkip; int mState; - SDL_Thread *mWorkerThread; - SDL_mutex *mMutex; - - typedef std::map<Uint16, MessageHandler*> MessageHandlers; + typedef std::map<unsigned short, MessageHandler*> MessageHandlers; typedef MessageHandlers::iterator MessageHandlerIterator; MessageHandlers mMessageHandlers; + std::queue<ENetPacket *> mOutgoingPackets; + std::queue<ENetPacket *> mIncomingPackets; + bool realConnect(); void receive(); }; |