コード例 #1
0
ファイル: Form1.cs プロジェクト: botelhorui/DAD
        private void button1_Click(object sender, EventArgs e)
        {
            String _clientPort = textBox2.Text;
            //CLIENT->SERVER
            TcpChannel channel = new TcpChannel();
            ChannelServices.RegisterChannel(channel, true);

            obj = (IServer)Activator.GetObject(
               typeof(IServer),
               "tcp://localhost:8086/ChatServer");

            //CLIENT<-SERVER
            IDictionary RemoteChannelProperties = new Hashtable();
            RemoteChannelProperties["port"] = _clientPort;
            RemoteChannelProperties["name"] = "tcp" + _clientPort;
            TcpChannel chan = new TcpChannel(RemoteChannelProperties, null, null);
            ChannelServices.RegisterChannel(chan, true);
            ChatClientRemote client = new ChatClientRemote(this);
            RemotingServices.Marshal(client, "ChatClient", typeof(ChatClientRemote));

            obj.registar(_clientPort);
        }