Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();

            #region Nhận yêu cầu từ client
            listView1.Items.Add("Service start now....");
            TcpChannel channel = new TcpChannel(2304);
            ChannelServices.RegisterChannel(channel);
            Type type = Type.GetType("FormRPC.XulyChoi");
            RemotingConfiguration.RegisterWellKnownServiceType(type, "Player1", WellKnownObjectMode.SingleCall);
            RemotingConfiguration.RegisterWellKnownServiceType(type, "Player2", WellKnownObjectMode.SingleCall);

            MsgContent.AddObject(this);
            #endregion
        }
Ejemplo n.º 2
0
        //Chọn cổng kết nối (dùng khi chạy trên 1 máy, IP trùng nhau)
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            //comboBox1.SelectedIndex = comboBox2.SelectedIndex;
            try
            {
                port = Convert.ToInt32(comboBox2.Text);
            }
            catch (Exception ex)
            {
                port = 0;
            }
            #region Nhận các phản hồi từ server
            TcpChannel channel2 = new TcpChannel(port);
            //ChannelServices.RegisterChannel(channel2);
            Type type2 = Type.GetType("FormRPC.testClient");
            RemotingConfiguration.RegisterWellKnownServiceType(type2, "Client", WellKnownObjectMode.SingleCall);

            MsgContent.AddObject(this);
            #endregion
        }
        public Form1()
        {
            InitializeComponent();

            #region Nhận yêu cầu từ client
            listView1.Items.Add("Service start now....");
            TcpChannel channel = new TcpChannel(2304);
            ChannelServices.RegisterChannel(channel);
            Type type = Type.GetType("FormRPC.Test");
            RemotingConfiguration.RegisterWellKnownServiceType(type, "Player1", WellKnownObjectMode.SingleCall);
            RemotingConfiguration.RegisterWellKnownServiceType(type, "Player2", WellKnownObjectMode.SingleCall);

            MsgContent.AddObject(this);
            #endregion

            #region Phản hồi lại client
            TcpChannel channel2 = new TcpChannel();
            //ChannelServices.RegisterChannel(channel2);
            type2 = typeof(Client);
            ti1   = (Client)Activator.GetObject(type2, "tcp://" + ipClient1 + ":2301/Client");
            ti2   = (Client)Activator.GetObject(type2, "tcp://" + ipClient2 + ":2302/Client");
            #endregion
        }