Beispiel #1
0
        // Connect to server
        private void ConnectToHangman()
        {
            try
            {
                // Configure the ABCs of using the MessageBoard service
                DuplexChannelFactory <IWords> channel = new DuplexChannelFactory <IWords>(this, "HangmanEndpoint");

                // Activate a MessageBoard object
                wordInstance = channel.CreateChannel();

                if (wordInstance.NewPlayer(tbName.Text))
                {
                    // Hide login, so they cant login again
                    LoginPanel.Visibility = Visibility.Hidden;
                    buttonPanel.IsEnabled = true;

                    // Set player board
                    SetPlayers();
                }
                else
                {
                    // New player name rejected by the service so nullify service proxies
                    wordInstance = null;
                    MessageBox.Show("ERROR: Username in use. Please try again.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }