Esempio n. 1
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            ChatClientServices.form = this;
            int        port = Int32.Parse(tb_Port.Text);
            TcpChannel chan = new TcpChannel(port);

            ChannelServices.RegisterChannel(chan, false);

            // Alternative 1 for service activation
            ChatClientServices servicos = new ChatClientServices();

            RemotingServices.Marshal(servicos, "ChatClient",
                                     typeof(ChatClientServices));

            // Alternative 2 for service activation
            //RemotingConfiguration.RegisterWellKnownServiceType(
            //    typeof(ChatClientServices), "ChatClient",
            //    WellKnownObjectMode.Singleton);

            IChatServer   server   = (IChatServer)Activator.GetObject(typeof(IChatServer), "tcp://localhost:8086/ChatServer");
            List <string> messages = server.RegisterClient(port.ToString());

            this.server = server;
            foreach (object o in messages)
            {
                AddMsg((string)o);
            }
        }