72{
73 std::shared_ptr<boost::mysql::tcp_ssl_connection> conn =
sZone->get_database_connection();
74
75 try {
77 boost::mysql::statement stmt = conn->prepare_statement("DELETE FROM `session_data` WHERE `current_server` = ? AND `last_update` < ?");
78 auto b1 = stmt.bind("Z", time);
79 boost::mysql::results results;
80 conn->execute(b1, results);
81
82 stmt = conn->prepare_statement("SELECT COUNT(`game_account_id`) FROM `session_data` WHERE `current_server` = ?");
83 auto b2 = stmt.bind("Z");
84 conn->execute(b2, results);
85
86 if (results.rows().empty()) {
87 HLog(info) <<
"There are no connected session(s).";
88 return;
89 }
90
91 int32_t
count = results.rows()[0][0].as_int64();
92
93 HLog(info) <<
count <<
" connected session(s).";
94 } catch (boost::mysql::error_with_diagnostics &err) {
95 HLog(error) <<
"Error while verifying connected sessions: " << err.what();
96 return;
97 }
98}
#define HLog(type)
Definition: Logger.hpp:122
#define sZone
Definition: Zone.hpp:247
size_t count(GridTypeListContainer< SPECIFIC_TYPE > const &elements, SPECIFIC_TYPE *)
Definition: GridReferenceContainer.hpp:100
std::time_t session_max_timeout()
Definition: Zone.hpp:125