summaryrefslogtreecommitdiff
path: root/src/net/tmwserv/logouthandler.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-04-07 15:10:13 -0600
committerJared Adams <jaxad0127@gmail.com>2009-04-07 15:10:13 -0600
commit3e8ed12a530426b3c649922452f42d9a2b2a8d89 (patch)
treeb8a36133854f772438144529d68dfb657e06fa4f /src/net/tmwserv/logouthandler.cpp
parent9eebc7ddac10c6c7f483bfd1003db79e61438bff (diff)
downloadmana-client-3e8ed12a530426b3c649922452f42d9a2b2a8d89.tar.gz
mana-client-3e8ed12a530426b3c649922452f42d9a2b2a8d89.tar.bz2
mana-client-3e8ed12a530426b3c649922452f42d9a2b2a8d89.tar.xz
mana-client-3e8ed12a530426b3c649922452f42d9a2b2a8d89.zip
Make GeneralHandlers for both networks
Also make Net::LogoutHandler
Diffstat (limited to 'src/net/tmwserv/logouthandler.cpp')
-rw-r--r--src/net/tmwserv/logouthandler.cpp63
1 files changed, 60 insertions, 3 deletions
diff --git a/src/net/tmwserv/logouthandler.cpp b/src/net/tmwserv/logouthandler.cpp
index 8b0e2d6e..9ac6c7d4 100644
--- a/src/net/tmwserv/logouthandler.cpp
+++ b/src/net/tmwserv/logouthandler.cpp
@@ -21,12 +21,25 @@
#include "net/tmwserv/logouthandler.h"
+#include "net/tmwserv/connection.h"
#include "net/tmwserv/protocol.h"
+#include "net/tmwserv/accountserver/accountserver.h"
+#include "net/tmwserv/chatserver/chatserver.h"
+#include "net/tmwserv/gameserver/gameserver.h"
+
#include "net/messagein.h"
#include "main.h"
+Net::LogoutHandler *logoutHandler;
+
+extern Net::Connection *gameServerConnection;
+extern Net::Connection *chatServerConnection;
+extern Net::Connection *accountServerConnection;
+
+namespace TmwServ {
+
LogoutHandler::LogoutHandler():
mPassToken(NULL),
mScenario(LOGOUT_EXIT),
@@ -42,6 +55,7 @@ LogoutHandler::LogoutHandler():
0
};
handledMessages = _messages;
+ logoutHandler = this;
}
void LogoutHandler::handleMessage(MessageIn &msg)
@@ -59,7 +73,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
switch (mScenario)
{
- case LOGOUT_SWITCH_ACCOUNTSERVER:
+ case LOGOUT_SWITCH_LOGIN:
if (mLoggedOutGame && mLoggedOutChat)
state = STATE_SWITCH_ACCOUNTSERVER;
break;
@@ -129,7 +143,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
if (mLoggedOutChat) state = STATE_RECONNECT_ACCOUNT;
break;
- case LOGOUT_SWITCH_ACCOUNTSERVER:
+ case LOGOUT_SWITCH_LOGIN:
if (mLoggedOutAccount && mLoggedOutChat)
state = STATE_SWITCH_ACCOUNTSERVER;
break;
@@ -170,7 +184,7 @@ void LogoutHandler::handleMessage(MessageIn &msg)
if (mLoggedOutGame) state = STATE_RECONNECT_ACCOUNT;
break;
- case LOGOUT_SWITCH_ACCOUNTSERVER:
+ case LOGOUT_SWITCH_LOGIN:
if (mLoggedOutAccount && mLoggedOutGame)
state = STATE_SWITCH_ACCOUNTSERVER;
break;
@@ -206,6 +220,47 @@ void LogoutHandler::setScenario(unsigned short scenario,
{
mScenario = scenario;
mPassToken = passToken;
+
+ // Can't logout if we were not logged in ...
+ if (mScenario == LOGOUT_EXIT)
+ {
+ if (accountServerConnection->isConnected())
+ Net::AccountServer::logout();
+ else
+ setAccountLoggedOut();
+
+ if (gameServerConnection->isConnected())
+ Net::GameServer::logout(false);
+ else
+ setGameLoggedOut();
+
+ if (chatServerConnection->isConnected())
+ Net::ChatServer::logout();
+ else
+ setChatLoggedOut();
+ }
+ else if (mScenario == LOGOUT_SWITCH_LOGIN)
+ {
+ if (accountServerConnection->isConnected())
+ Net::AccountServer::logout();
+ else
+ setAccountLoggedOut();
+
+ if (gameServerConnection->isConnected())
+ Net::GameServer::logout(false);
+ else
+ setGameLoggedOut();
+
+ if (chatServerConnection->isConnected())
+ Net::ChatServer::logout();
+ else
+ setChatLoggedOut();
+ }
+ else if (mScenario == LOGOUT_SWITCH_CHARACTER)
+ {
+ Net::GameServer::logout(true);
+ Net::ChatServer::logout();
+ }
}
void LogoutHandler::reset()
@@ -216,3 +271,5 @@ void LogoutHandler::reset()
mLoggedOutGame = false;
mLoggedOutChat = false;
}
+
+} // namespace TmwServ