Пример #1
0
        public frmRCleint()
        {
            InitializeComponent();

            //************************************* TCP *************************************//
            // using TCP protocol
            // running both client and server on same machines
            //TcpChannel chan = new TcpChannel();
            //˫���ŵ�
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
            IDictionary props = new Hashtable();
            props["port"] = 0;//���ն˿�(���)
            TcpChannel chan = new TcpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(chan,false);
            // Create an instance of the remote object
            remoteObject = (MyRemotableObject) Activator.GetObject(typeof(MyRemotableObject),"tcp://localhost:8080/HelloWorld");
            // if remote object is on another machine the name of the machine should be used instead of localhost.
            //************************************* TCP *************************************//
            wrapper = new EventWrapper();//�¼���װ������
            wrapper.LocalEvent += new ServerEventHandler(OnServerEvent);
            remoteObject.ServerEvent += new ServerEventHandler(wrapper.Response);
        }
        public frmRCleint()
        {
            //************************************* TCP *************************************//
            // using TCP protocol
            // running both client and server on same machines
            TcpChannel chan = new TcpChannel();

            ChannelServices.RegisterChannel(chan, false);
            // Create an instance of the remote object
            remoteObject = (MyRemotableObject)Activator.GetObject(typeof(MyRemotableObject), "tcp://localhost:8080/HelloWorld");
            // if remote object is on another machine the name of the machine should be used instead of localhost.
            //************************************* TCP *************************************//
        }
Пример #3
0
        public frmRServer()
        {
            InitializeComponent();
            remotableObject = new MyRemotableObject();

            //************************************* TCP *************************************//
            // using TCP protocol
            //TcpChannel channel = new TcpChannel(8080);
            //˫���ŵ�
            BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
            serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
            IDictionary props = new Hashtable();
            props["port"] = 8080;
            TcpChannel channel = new TcpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel,false);
            //RemotingConfiguration.RegisterWellKnownServiceType(typeof(MyRemotableObject),"HelloWorld",WellKnownObjectMode.Singleton);
            ObjRef objRef = RemotingServices.Marshal(remotableObject, "HelloWorld");//server �� client �㲥��Ϣ
            //************************************* TCP *************************************//
            RemotableObjects.Cache.Attach(this);
        }
Пример #4
0
        public void Notify(object sender, string text)
        {
            if (InvokeRequired)
            {
                Invoke(new NotifyDelegate(Notify), sender, text);
                return;
            }

            richTextBox1.SelectionColor = Color.LimeGreen;
            richTextBox1.SelectionFont = new Font("宋体", 9);
            richTextBox1.AppendText("\r\n" + text);
            richTextBox1.AppendText("\r\n");

            if (ec.m_ConnectionState == StateClass.ConnectionState.Logined)
            {
                remotableObject = (MyRemotableObject)sender;

                if (text.ToUpper().Trim().StartsWith("RT"))
                {
                    //此构造函数可以提取团队中的姓名等特殊数据
                    RTWithNMAndPrice(text);
                }
                else if (text.ToUpper().Trim().StartsWith("AV"))
                {
                    GetFlights(text);
                }
            }
            else
            {
                remotableObject = (MyRemotableObject)sender;
                remotableObject.ResultString = "服务器ETERM未登陆 或 执行了RT以外的指令\r\rCommand:" + text;
                remotableObject.Set();
            }
        }