Beispiel #1
0
    def __init__(self, remote='127.0.0.1', port=5050, player: Player = None):
        self.remote = remote
        self.port = port
        self.address = (remote, port)
        self.player = player
        self.app_logger = L.create_logger('CLIENT_MAIN',
                                          logging.INFO,
                                          to_file=True)
        self.communication_logger = L.create_logger('Hangman client',
                                                    logging.INFO)

        self.app_logger.info(f'Starting client... src={SRC}/__init__:41')
        self.communication_logger.info('Welcome to the hangman client!')
Beispiel #2
0
 def __init__(self, host='', port=5050, max_connections=5):
     """
     Initialise the server.
     :param host: the host's IPv4 address to bind the server to.
     :param port: the port to bind the server to. Default = 5050.
     :param max_connections: the maximum number of connections the server will queue before dropping the next.
     """
     self.logger_file = L.create_logger('SERVER_MAIN', logging.INFO, to_file=True)
     self.logger_info = L.create_logger('SERVER_MAIN_COMM', logging.INFO, to_file=False)
     self.host = host
     self.port = port
     self.address = (host, port)
     self.groups = []
     self.events = []
     self.max_connections = max_connections
Beispiel #3
0
 def __init__(self, server_socket: socket, events: list):
     super().__init__()
     self.socket = server_socket
     self.events = events
     self.logger = Logger.create_logger('SERVER_INPUT',
                                        logging.INFO,
                                        to_file=True)
Beispiel #4
0
    def __init__(self, assigned_groups: list, lock: Lock, add_event_to_server):
        """
        Initialise the group manager.
        :param assigned_groups: the groups this manager will manage.
        :param lock: a thread lock to ensure the Game thread does not access its group at the same time as this manager.
        :param add_event_to_server: a reference to the corresponding server's add_terminal_event method.
        """
        super().__init__()
        self.terminal_event = Event()
        self.groups = assigned_groups
        self.logger = Logger.create_logger(self.__repr__(),
                                           logging.INFO,
                                           to_file=True)
        self.games = []
        self.lock = lock

        add_event_to_server(self.terminal_event)
Beispiel #5
0
 def __init__(self, player: Player, lock: Lock, groups: list):
     super().__init__()
     self.player = player
     self.logger = Logger.create_logger(self.__repr__(), logging.INFO, to_file=True)
     self.lock = lock
     self.groups = groups