Add error code to onError protocol event

This commit is contained in:
Eduardo Bart
2012-07-09 19:45:34 -03:00
parent 59f75d996e
commit e7691b873b
7 changed files with 30 additions and 22 deletions

View File

@@ -34,9 +34,9 @@ SET(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
IF(USE_STATIC_LIBS)
SET(CMAKE_CXX_LINK_FLAGS "-static-libgcc -static-libstdc++")
MESSAGE("Link to static libraries: ON")
MESSAGE(STATUS "Link to static libraries: ON")
ELSE()
MESSAGE("Link to static libraries: OFF")
MESSAGE(STATUS "Link to static libraries: OFF")
ENDIF()
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})

View File

@@ -242,6 +242,6 @@ void Protocol::onRecv(const InputMessagePtr& inputMessage)
void Protocol::onError(const boost::system::error_code& err)
{
callLuaField("onError", err.message(), true);
callLuaField("onError", err.message(), err.value());
disconnect();
}

View File

@@ -64,13 +64,13 @@ void Game::resetGameStates()
m_gmActions.clear();
}
void Game::processConnectionError(const boost::system::error_code& error)
void Game::processConnectionError(const boost::system::error_code& ec)
{
// connection errors only have meaning if we still have a protocol
if(m_protocolGame) {
// eof = end of file, a clean disconnect
if(error != asio::error::eof)
g_lua.callGlobalField("g_game", "onConnectionError", error.message());
if(ec != asio::error::eof)
g_lua.callGlobalField("g_game", "onConnectionError", ec.message(), ec.value());
processDisconnect();
}

View File

@@ -42,6 +42,8 @@ void ProtocolGame::login(const std::string& accountName, const std::string& acco
void ProtocolGame::onConnect()
{
Protocol::onConnect();
// must create local player before parsing anything
m_localPlayer = LocalPlayerPtr(new LocalPlayer);
@@ -56,12 +58,16 @@ void ProtocolGame::onConnect()
void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
{
//Protocol::onConnect(inputMessage);
parseMessage(inputMessage);
recv();
}
void ProtocolGame::onError(const boost::system::error_code& error)
{
Protocol::onError(error);
g_game.processConnectionError(error);
}