예제 #1
0
        //load window
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DuplexChannelFactory <IDGBizController> DGBiz;

            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;

            string sURL = "net.tcp://localhost:50002/DGBiz";

            try
            {
                //connect to Biz Tier
                DGBiz   = new DuplexChannelFactory <IDGBizController>(this, tcpBinding, sURL);
                m_DGBiz = DGBiz.CreateChannel();
            }
            catch (CommunicationObjectFaultedException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
        //load window
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DuplexChannelFactory <IDGBizController> DGBiz;

            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;

            string sURL = "net.tcp://localhost:50002/DGBiz";

            try
            {
                //connect to Biz Tier
                DGBiz   = new DuplexChannelFactory <IDGBizController>(this, tcpBinding, sURL);
                m_DGBiz = DGBiz.CreateChannel();
            }
            catch (CommunicationObjectFaultedException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }

            //Setup page
            welcome.Content = "welcome " + username;
            try
            {
                m_DGBiz.RegisterClient(username);
                serverList   = m_DGBiz.GetServerList();
                friendIDList = m_DGBiz.GetFriendID(userID);
                m_DGBiz.ChangeUserState(userID, "online");
                m_DGBiz.NotifyServer();
                m_DGBiz.NotifyServerState();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }