Пример #1
0
        /// <summary>
        /// Méthode exécutée à la fermeture de la fenêtre
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Partie_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Initialisation d'un nouvel objet de transfert de données en indiquant que l'on ferme la fenêtre
            dt       = new DataTransit();
            dt.Alive = false;
            this.updateOutputLog("Fermeture de la partie en cours", 0);

            // On envois les données et on ferme la connexion
            if (joueur == 1)
            {
                ClientClass.prepareSendData(dt);
                this.form.changeScanButtonActivate(true);
                ClientClass.CloseConnection();
                this.Dispose();
            }
            else
            {
                ServerClass.prepareSendData(dt);
                this.form.changeServerButtonActivate(true);
                ServerClass.CloseConnection();
                this.Dispose();
                this.form.InvokeClickServer();
            }

            // La fenêtre de configuration Bluetooth est réaffichée
            this.form.ChangeVisibily(true);
        }
Пример #2
0
 /// <summary>
 /// Méthode dédiée à la gestion du click sur le bouton Stop
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void stop_action(object sender, EventArgs e)
 {
     serveur.Enabled     = true;
     scan_button.Enabled = true;
     textBox1.Enabled    = true;
     this.updateConsoleLog("Fermeture des connexions", -1);
     if (svr != null)
     {
         ServerClass.CloseConnection();
     }
     if (clt != null)
     {
         ClientClass.CloseConnection();
     }
 }
Пример #3
0
 /// <summary>
 ///  Méthode de lancement pour la création du serveur */
 /// </summary>
 public void connectAsServer()
 {
     this.updateOutputLog("Launching Server ...", 0);
     bluetoothServerThread = new Thread(new ThreadStart(start_server));
     bluetoothServerThread.IsBackground = true;
     if (!serverLaunch)
     {
         try{
             bluetoothServerThread.Start();
         }catch (ThreadStartException th) {
             this.updateOutputLog(th.Message, -1);
             ServerClass.CloseConnection();
         }
     }
     else
     {
         this.updateOutputLog("Server already launched", 0);
     }
     serverLaunch = true;
 }