add mysql check function
This commit is contained in:
parent
6313ff569f
commit
1dc9cd4216
14
cpp/utils.cc
14
cpp/utils.cc
@ -120,6 +120,20 @@ namespace f8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckMysqlConnection(a8::mysql::Connection* conn, a8::mysql::Query* query,
|
||||||
|
std::string dbhost, int port, std::string dbuser, std::string dbpasswd, std::string gamedb)
|
||||||
|
{
|
||||||
|
if (query->ExecQuery("SELECT 1;", {}) <= 0) {
|
||||||
|
a8::UdpLog::Instance()->Warning("mysql disconnect", {});
|
||||||
|
if (conn->Connect(dbhost, 3306, dbuser, dbpasswd, gamedb)) {
|
||||||
|
f8::InitMysqlConnection(query);
|
||||||
|
a8::UdpLog::Instance()->Info("mysql reconnect successed", {});
|
||||||
|
} else {
|
||||||
|
a8::UdpLog::Instance()->Info("mysql reconnect failed", {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CheckRegisterTimeInSessionId(const std::string& accountid, const std::string& sessionid)
|
bool CheckRegisterTimeInSessionId(const std::string& accountid, const std::string& sessionid)
|
||||||
{
|
{
|
||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
|
@ -13,6 +13,7 @@ namespace a8
|
|||||||
{
|
{
|
||||||
namespace mysql
|
namespace mysql
|
||||||
{
|
{
|
||||||
|
class Connection;
|
||||||
class Query;
|
class Query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,6 +79,8 @@ namespace f8
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InitMysqlConnection(a8::mysql::Query* query);
|
void InitMysqlConnection(a8::mysql::Query* query);
|
||||||
|
void CheckMysqlConnection(a8::mysql::Connection* conn, a8::mysql::Query* query,
|
||||||
|
std::string dbhost, int port, std::string dbuser, std::string dbpasswd, std::string gamedb);
|
||||||
|
|
||||||
bool CheckRegisterTimeInSessionId(const std::string& accountid, const std::string& sessionid);
|
bool CheckRegisterTimeInSessionId(const std::string& accountid, const std::string& sessionid);
|
||||||
time_t ExtractRegisterTimeFromSessionId(const std::string& sessionid);
|
time_t ExtractRegisterTimeFromSessionId(const std::string& sessionid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user