Exemple #1
0
    def manual_connexion_button_command(self):
        """
        When the button manual connexion is clicked
        :return: None
        """
        try:
            host = socket.gethostbyname(
                self.manual_connexion_host_string_var.get())
        except socket.gaierror:
            tkinter.messagebox.showerror(
                self.ui.translation.get_translation(
                    "server_list_dialog_host_error_title"),
                self.ui.translation.get_translation(
                    "server_list_dialog_host_error_message").format(
                        Server.get_ip()))
            return None
        port = self.manual_connexion_port.get()

        try:
            port = int(port)
        except ValueError:
            tkinter.messagebox.showerror(
                self.ui.translation.get_translation(
                    "server_configuration_dialog_port_error_title"),
                self.ui.translation.get_translation(
                    "server_configuration_dialog_port_error_message"))
            return None

        if not (3000 <= port <= 3020):
            tkinter.messagebox.showerror(
                self.ui.translation.get_translation(
                    "server_configuration_dialog_port_error_title"),
                self.ui.translation.get_translation(
                    "server_configuration_dialog_port_error_message"))
            return None

        if Server.exist(host, port):
            self.ui.client = Client(host, port)
            if self.ui.client.connect():
                self.ui.change_panel(
                    ServerGameConfigurationPanel.ServerGameConfigurationPanel,
                    create_game=False)
        else:
            tkinter.messagebox.showerror(
                self.ui.translation.get_translation(
                    "server_list_dialog_unreachable_title"),
                self.ui.translation.get_translation(
                    "server_list_dialog_unreachable_message"))
            return
 def button_play_server_command(self, host_port):
     """
     When the button to play with a server
     :param host_port: host and port of the server
     :return: None
     """
     if Server.exist(host_port[0], host_port[1]):
         self.ui.client = Client(host_port[0], host_port[1])
         if self.ui.client.connect():
             self.ui.change_panel(
                 ServerGameConfigurationPanel.ServerGameConfigurationPanel,
                 is_server=False)
     else:
         self.server_scanner_server_detection(ServerScanner.SERVER_REMOVE,
                                              host_port)