Added connection_time and idle_time properties to DefaultCharacter class.
This commit is contained in:
parent
9522a94ece
commit
270037455a
1 changed files with 21 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ These are the (default) starting points for all in-game visible
|
||||||
entities.
|
entities.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import time
|
||||||
from builtins import object
|
from builtins import object
|
||||||
from future.utils import listvalues, with_metaclass
|
from future.utils import listvalues, with_metaclass
|
||||||
|
|
||||||
|
|
@ -1463,6 +1464,26 @@ class DefaultCharacter(DefaultObject):
|
||||||
self.db.prelogout_location = self.location
|
self.db.prelogout_location = self.location
|
||||||
self.location = None
|
self.location = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def idle_time(self):
|
||||||
|
"""
|
||||||
|
Returns the idle time of the least idle session in seconds. If
|
||||||
|
no sessions are connected it returns nothing.
|
||||||
|
"""
|
||||||
|
idle = [session.cmd_last_visible for session in self.sessions.all()]
|
||||||
|
if idle:
|
||||||
|
return time.time() - float(max(idle))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def connection_time(self):
|
||||||
|
"""
|
||||||
|
Returns the maximum connection time of all connected sessions
|
||||||
|
in seconds. Returns nothing if there are no sessions.
|
||||||
|
"""
|
||||||
|
conn = [session.conn_time for session in self.sessions.all()]
|
||||||
|
if conn:
|
||||||
|
return time.time() - float(min(conn))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Base Room object
|
# Base Room object
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue