コード例 #1
0
 //decide hero
 private void btn_Go_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (!pressGO)
         {
             pressGO = true;
             m_DGSer.AddNumberOfPlayer();
             m_DGSer.AddHeroSelectTimes(selectedHeroID);
             m_DGSer.NotifyServer();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DuplexChannelFactory <IDGSerController> DGSer;

            NetTcpBinding tcpBinding = new NetTcpBinding();

            //release the limitation of the size of message which can be sent
            tcpBinding.MaxReceivedMessageSize      = System.Int32.MaxValue;
            tcpBinding.ReaderQuotas.MaxArrayLength = System.Int32.MaxValue;

            try
            {
                //connect to Server Tier
                DGSer   = new DuplexChannelFactory <IDGSerController>(this, tcpBinding, server_URL);
                m_DGSer = DGSer.CreateChannel();
            }
            catch (CommunicationObjectFaultedException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }

            //set up page information
            user.Content = "Welcome " + username + ", \nplease select a hreo and press \"GO\" to enter the battle.";
            pressGO      = false;

            try
            {
                m_DGSer.RegisterClient(username);
                heroInfoList     = m_DGSer.GetHeroInfoList();
                heroNameList     = m_DGSer.GetHeroNameList();
                selectedBossInfo = m_DGSer.GetSelectedBossInfo();
                setupInfo();
                m_DGSer.NotifyServer();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }