diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-19 17:29:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-19 18:22:41 +0300 |
commit | 30d18cb5d0834132853fb14d45828582b42a8f6e (patch) | |
tree | aa1cc9fa09e3ae5601d412772856514874c573a6 /src/net/eathena/network.h | |
parent | 94d65b487d458341e3626bcfa41fa09c1c240d89 (diff) | |
download | mv-30d18cb5d0834132853fb14d45828582b42a8f6e.tar.gz mv-30d18cb5d0834132853fb14d45828582b42a8f6e.tar.bz2 mv-30d18cb5d0834132853fb14d45828582b42a8f6e.tar.xz mv-30d18cb5d0834132853fb14d45828582b42a8f6e.zip |
Move some code from network to base classes.
Diffstat (limited to 'src/net/eathena/network.h')
-rw-r--r-- | src/net/eathena/network.h | 63 |
1 files changed, 3 insertions, 60 deletions
diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h index 1fdcf7c6e..0ce8591ff 100644 --- a/src/net/eathena/network.h +++ b/src/net/eathena/network.h @@ -23,6 +23,8 @@ #ifndef NET_EATHENA_NETWORK_H #define NET_EATHENA_NETWORK_H +#include "net/ea/network.h" + #include "net/serverinfo.h" #include "net/eathena/messagehandler.h" @@ -44,89 +46,30 @@ namespace EAthena { -class Network +class Network : public Ea::Network { public: Network(); ~Network(); - bool connect(ServerInfo server); - - void disconnect(); - - ServerInfo getServer() const - { return mServer; } - void registerHandler(MessageHandler *handler); void unregisterHandler(MessageHandler *handler); void clearHandlers(); - int getState() const - { return mState; } - - const std::string &getError() const - { return mError; } - - bool isConnected() const - { return mState == CONNECTED; } - - int getInSize() const - { return mInSize; } - - void skip(int len); - bool messageReady(); MessageIn getNextMessage(); void dispatchMessages(); - void flush(); - - void fixSendBuffer(); - - // ERROR replaced by NET_ERROR because already defined in Windows - enum - { - IDLE = 0, - CONNECTED, - CONNECTING, - DATA, - NET_ERROR - }; - protected: - friend int networkThread(void *data); friend class MessageOut; static Network *instance(); - void setError(const std::string &error); - - uint16_t readWord(int pos); - - bool realConnect(); - - void receive(); - - TCPsocket mSocket; - - ServerInfo mServer; - - char *mInBuffer, *mOutBuffer; - unsigned int mInSize, mOutSize; - - unsigned int mToSkip; - - int mState; - std::string mError; - - SDL_Thread *mWorkerThread; - SDL_mutex *mMutex; - typedef std::map<uint16_t, MessageHandler*> MessageHandlers; typedef MessageHandlers::iterator MessageHandlerIterator; MessageHandlers mMessageHandlers; |