#!/usr/bin/env python #coding=utf8 from datetime import datetime class CCClient(object): ''' Represent a single client connected to the server. ''' def __init__(self, login, role, server, connection): # The login of the client: self.login = login # The role of the client: self.role = role # The server binded to this client: self.server = server # The connection of the client (public attribute): self.connection = connection # The date of connection of the client: self._connection_date = datetime.now() def get_uptime(self): ''' Get the uptime of the client connection in seconds. :return: uptime of the client ''' dt = datetime.now() - self._connection_date return dt.seconds + dt.days * 86400