Fix issue #2926
wesnothd: implement support for printing time for which user was connected in /query status and /query searchlog
This commit is contained in:
parent
e5a0400721
commit
ca9dd3a8d8
2 changed files with 6 additions and 2 deletions
|
@ -34,7 +34,8 @@ class player_record
|
|||
public:
|
||||
template<class SocketPtr>
|
||||
player_record(const SocketPtr socket, const player& player)
|
||||
: socket_(socket)
|
||||
: login_time(std::chrono::steady_clock::now())
|
||||
, socket_(socket)
|
||||
, player_(player)
|
||||
, game_()
|
||||
, ip_address(client_address(socket))
|
||||
|
@ -71,6 +72,8 @@ public:
|
|||
|
||||
void enter_lobby();
|
||||
|
||||
const std::chrono::time_point<std::chrono::steady_clock> login_time;
|
||||
|
||||
private:
|
||||
const any_socket_ptr socket_;
|
||||
mutable player player_;
|
||||
|
|
|
@ -191,7 +191,8 @@ static bool make_change_diff(const simple_wml::node& src,
|
|||
static std::string player_status(const wesnothd::player_record& player)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "'" << player.name() << "' @ " << player.client_ip();
|
||||
out << "'" << player.name() << "' @ " << player.client_ip()
|
||||
<< " logged on for " << lg::get_timespan(std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - player.login_time).count());
|
||||
return out.str();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue