Пример #1
0
 private void ClearUser()
 {
     if (IsActive)
     {
         if (MainWindow.CountPlayingUsers() <= 2)
         {
             MainWindow.NotEnoughPlayers();
         }
         if (IsPlaying)
         {
             Status    = STATUS.FOLD;
             IsPlaying = false;
         }
         for (int i = 0; i < MainWindow.usersHistory.Count; i++)
         {
             if (MainWindow.usersHistory[i].uID == UserData.uID)
             {
                 MainWindow.usersHistory[i] = new UserData(UserData);
             }
         }
         UserData = default;
         if (RemoteClient != null)
         {
             RemoteClient.Close();
             RemoteClient.Dispose();
             RemoteClient = null;
         }
         JoiningManagement.Refresh();
     }
 }
Пример #2
0
 public virtual void Stop()
 {
     if (m_remoteClient != null)
     {
         m_remoteClient.Close();
     }
     StopAllCoroutines();
 }
Пример #3
0
        private void ConnectButtonClick(object sender, RoutedEventArgs e)
        {
            if(string.IsNullOrEmpty(ServerBox.Text) || string.IsNullOrEmpty(PasswordBox.Password))
            {
                System.Windows.MessageBox.Show("You didn't fill in the required fields.", "Error!",
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                return;
            }

            try
            {
                _server = ServerBox.Text;
                _password = PasswordBox.Password;
                _rmc = new RemoteClient("BasicHttpBinding_IRemote",
                                           new EndpointAddress(_server));

                _rmc.Open();

                if(!_rmc.Authorize(Utility.MD5String(_password)))
                {
                    System.Windows.MessageBox.Show("Invalid password entered!", "Error!", MessageBoxButton.OK,
                                    MessageBoxImage.Error);

                    _rmc.Close();

                    return;
                }

            }
            catch(Exception x)
            {
                System.Windows.MessageBox.Show(string.Format("Something unexpexted happened! Please report this to devs!{0}{1}---------------------------------------------------------------------------{2}{3}",
                    Environment.NewLine,
                    Environment.NewLine,
                    Environment.NewLine,
                    x), "Error!",   MessageBoxButton.OK,
                                    MessageBoxImage.Error);

                _rmc.Close();

                return;
            }

            MessageTab.IsEnabled = true;

            System.Windows.MessageBox.Show("Connection successful!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
            _connected = true;
        }
Пример #4
0
 private void DisconnectHandler(RemoteClient client)
 {
     if (client.Player != null)
     {
         game.Despawn(client.Player);
     }
     lock (clients){
         if (clients.IndexOf(client) >= 0)
         {
             clients.Remove(client);
         }
     }
     client.Close();
     game.Post("Client disconnected");
 }
Пример #5
0
        /// <summary>
        /// Disconnects this connection.
        /// </summary>
        public void Disconnect()
        {
            if (_disconnectCalls > 0)
            {
                return;
            }

            _disconnectCalls++;
            _writeDone.WaitOne();

            try
            {
                ClientDisconnected(this, EventArgs.Empty);
            }
            catch
            {
                // ignore
            }

            try
            {
#if !NET452
                RemoteClient.Dispose();
                SecureStream?.Dispose();
                NetworkStream?.Dispose();
#else
                RemoteClient.Close();
                SecureStream?.Close();
                NetworkStream?.Close();
#endif
            }
            catch
            {
                // ignored
            }
            finally
            {
                NetworkStream            = null;
                SecureStream             = null;
                RemoteClient             = null;
                _continuousReadingThread = null;
            }
        }
Пример #6
0
 public void Close()
 {
     _client.Close();
 }