Пример #1
0
        private void connectButton_Click(object sender, EventArgs e)
        {
            if (nickTextBox.Text != "" && portTextBox.Text != "")
            {
                nick = nickTextBox.Text;
                port = Convert.ToInt32(portTextBox.Text);

                // Iniciar canal
                channel = new TcpChannel(port);
                ChannelServices.RegisterChannel(channel, false);

                // Registro do Servidor
                server = (IChatServer)Activator.GetObject(
                    typeof(IChatServer),
                    "tcp://localhost:8086/ChatServer" //lacking null verification
                    );

                // Registro do cliente
                RemoteChatClient rmc = new RemoteChatClient(this);
                String           clientServiceName = "ChatClient";
                RemotingServices.Marshal(
                    rmc,
                    clientServiceName,
                    typeof(RemoteChatClient)
                    );

                if (server != null)
                {
                    // opcional
                    server.connect(nick, "tcp://localhost:" + port + "/" + clientServiceName);
                }
            }
        }
Пример #2
0
        private void connectButton_Click(object sender, EventArgs e)
        {
            if (nickTextBox.Text != "" && portTextBox.Text != "")
            {
                nick = nickTextBox.Text;
                port = Convert.ToInt32(portTextBox.Text);

                // Iniciar canal
                channel = new TcpChannel(port);
                ChannelServices.RegisterChannel(channel, false);

                // Registro do Servidor
                server = (IChatServer)Activator.GetObject(
                    typeof(IChatServer),
                    "tcp://localhost:8086/ChatServer" //lacking null verification
                );

                // Registro do cliente
                RemoteChatClient rmc = new RemoteChatClient(this);
                String clientServiceName = "ChatClient";
                RemotingServices.Marshal(
                    rmc,
                    clientServiceName,
                    typeof(RemoteChatClient)
                );

                if (server != null)
                {
                    // opcional
                    server.connect(nick, "tcp://localhost:" + port + "/" + clientServiceName);
                }
            }
        }