|
|
@@ -10,12 +10,15 @@ CServer::CServer()
|
|
|
|
|
|
CServer::~CServer()
|
|
|
{
|
|
|
+ LOG_ERROR("start ~CServer");
|
|
|
delete acceptor_;
|
|
|
|
|
|
if (m_db != NULL)
|
|
|
{
|
|
|
sqlite3_close(m_db);
|
|
|
}
|
|
|
+
|
|
|
+ LOG_ERROR("end ~CServer");
|
|
|
}
|
|
|
|
|
|
void CServer::Init()
|
|
|
@@ -62,8 +65,19 @@ void CServer::Init()
|
|
|
t.detach();
|
|
|
}
|
|
|
|
|
|
- //开始异步执行
|
|
|
- io_context_.run();
|
|
|
+ LOG_ERROR("ready to run");
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //开始异步执行
|
|
|
+ io_context_.run();
|
|
|
+ }
|
|
|
+ catch (std::exception& e)
|
|
|
+ {
|
|
|
+ LOG_ERROR("io_context Exception: " << e.what());
|
|
|
+ }
|
|
|
+
|
|
|
+ LOG_ERROR("stop run");
|
|
|
}
|
|
|
|
|
|
void CServer::InitSqlLite()
|
|
|
@@ -282,12 +296,15 @@ void CServer::start_accept()
|
|
|
void CServer::handle_accept(CClientSession* new_session,
|
|
|
const boost::system::error_code& error)
|
|
|
{
|
|
|
+ //LOG_INFO("new client, handle_accept!");
|
|
|
+
|
|
|
if (!error)
|
|
|
{
|
|
|
new_session->start();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ LOG_ERROR("handle_accept error");
|
|
|
delete new_session;
|
|
|
}
|
|
|
|
|
|
@@ -311,6 +328,8 @@ void CServer::BindUsername(std::string username, CClientSession* session)
|
|
|
m_clients_map[username] = session;
|
|
|
|
|
|
m_map_mutex.unlock();
|
|
|
+
|
|
|
+ LOG_INFO("绑定新客户端成功,当前客户端数量:" << m_clients_map.size());
|
|
|
}
|
|
|
|
|
|
void CServer::DeleteClient(std::string username)
|
|
|
@@ -323,6 +342,8 @@ void CServer::DeleteClient(std::string username)
|
|
|
}
|
|
|
|
|
|
m_map_mutex.unlock();
|
|
|
+
|
|
|
+ LOG_INFO("删除客户端成功,当前客户端数量:" << m_clients_map.size());
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
@@ -349,13 +370,15 @@ void CServer::ReceiveMNSMessage()
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ //LOG_INFO("new msn message:" << message.c_str());
|
|
|
+
|
|
|
//获取到了新的消息,开始进行处理
|
|
|
rapidjson::Document document;
|
|
|
document.Parse(message.c_str());
|
|
|
if(!document.IsObject())
|
|
|
{
|
|
|
- LOG_ERROR("message 非法!");
|
|
|
- LOG_ERROR("get new message:" << message.c_str());
|
|
|
+ LOG_INFO("message 非法!");
|
|
|
+ LOG_INFO("get new message:" << message.c_str());
|
|
|
continue;
|
|
|
}
|
|
|
|