Beispiel #1
0
        private void connectToMessageBoard()
        {
            try
            {
                // Configure the ABCs of using the MessageBoard service
                DuplexChannelFactory <IShoe> channel = new DuplexChannelFactory <IShoe>(this, "ShoeEndPoint");

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

                if (shoe.Join(nameTxtBox.Text))
                {
                    // Alias accepted by the service so update GUI
                    boardListBox.ItemsSource   = shoe.GetAllMessages();
                    playersListBox.ItemsSource = shoe.GetAllPlayers();
                    nameTxtBox.IsEnabled       = nameSetBtn.IsEnabled = false;
                }
                else
                {
                    // Alias rejected by the service so nullify service proxies
                    shoe = null;
                    MessageBox.Show("ERROR: Alias in use. Please try again.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        // *******************  Helper methods    **********************

        private void connectToCardTable()
        {
            try
            {
                // Connect to the Shoe service using DUPLEX channel (for callbacks)
                DuplexChannelFactory <IShoe> channel = new DuplexChannelFactory <IShoe>(this, "ShoeEndPoint");
                shoe = channel.CreateChannel();

                if (shoe.Join(txtAlias.Text))
                {
                    // Deal two cards to each player and the dealer in the first round
                    for (int i = 0; i < 2; i++)
                    {
                        Card card = shoe.Deal();

                        // Update the current player info
                        myLstCards.Items.Insert(0, card);
                    }

                    UpdateCurrentPlayerInfo(CalculatePoints());

                    txtAlias.IsEnabled = btnSet.IsEnabled = false;
                }
                else
                {
                    // Alias rejected by the service so nullify service proxies
                    shoe = null;
                    txtAlias.IsEnabled = btnSet.IsEnabled = true;
                    MessageBox.Show("ERROR: Alias in use. Please try again.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }