summaryrefslogtreecommitdiff
path: root/src/net/network.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/network.h')
-rw-r--r--src/net/network.h59
1 files changed, 35 insertions, 24 deletions
diff --git a/src/net/network.h b/src/net/network.h
index eb2ce8ab..49583b9d 100644
--- a/src/net/network.h
+++ b/src/net/network.h
@@ -36,8 +36,6 @@ class MessageHandler;
class MessageIn;
class MessageOut;
-class Network;
-
class Network
{
public:
@@ -46,35 +44,53 @@ class Network
Network();
~Network();
- bool connect(const std::string &address, short port);
- void disconnect();
+ typedef enum {
+ ACCOUNT,
+ GAME,
+ CHAT
+ } Server;
+
+ bool
+ connect(Server server, const std::string &address, short port);
+
+ void
+ disconnect(Server server);
+
+ void
+ registerHandler(MessageHandler *handler);
+
+ void
+ unregisterHandler(MessageHandler *handler);
- void registerHandler(MessageHandler *handler);
- void unregisterHandler(MessageHandler *handler);
- void clearHandlers();
+ void
+ clearHandlers();
- int getState() const { return mState; }
- bool isConnected() const { return mState == CONNECTED; }
+ int
+ getState() const { return mState; }
- void dispatchMessage(ENetPacket *packet);
- void flush();
+ bool
+ isConnected(Server server) const;
- void send(const MessageOut &msg);
+ void
+ dispatchMessage(ENetPacket *packet);
+
+ void
+ flush();
+
+ void
+ send(Server server, const MessageOut &msg);
enum State {
- IDLE,
- CONNECTED,
- CONNECTING,
- DATA,
+ NET_OK,
NET_ERROR
};
private:
ENetHost *mClient;
- ENetPeer *mServer;
- std::string mAddress;
- short mPort;
+ ENetPeer *mAccountServer;
+ ENetPeer *mGameServer;
+ ENetPeer *mChatServer;
unsigned int mToSkip;
@@ -83,11 +99,6 @@ class Network
typedef std::map<unsigned short, MessageHandler*> MessageHandlers;
typedef MessageHandlers::iterator MessageHandlerIterator;
MessageHandlers mMessageHandlers;
-
- std::queue<ENetPacket *> mOutgoingPackets;
-
- bool realConnect();
- void receive();
};
/** Convert an address from int format to string */