Пример #1
0
        private void sendPrivateButton_Click(object sender, System.EventArgs e)
        {
            using (SendPrivateMessageDialog spmd = new SendPrivateMessageDialog())
            {
                this.Cursor = Cursors.WaitCursor;
                Server server = (Server)Activator.GetObject(
                    typeof(Server),
                    "tcp://localhost:8085/ChatServer");
                if (server == null)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("could not locate server");
                    return;
                }
                else
                {
                    try
                    {
                        spmd.ClientNames = server.ClientNames;
                        this.Cursor      = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show("an error occurred: " + ex.Message);
                        return;
                    }
                }

                if (spmd.ShowDialog() == DialogResult.OK)
                {
                    this.Cursor = Cursors.WaitCursor;
                    try
                    {
                        server.PostPrivateMessage(this.client, spmd.ClientName, spmd.MessageText);
                        this.Cursor = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show("an error occurred: " + ex.Message);
                        return;
                    }
                }
            }
        }
Пример #2
0
        private void sendPrivateButton_Click(object sender, System.EventArgs e)
        {
            using (SendPrivateMessageDialog spmd = new SendPrivateMessageDialog())
            {
                this.Cursor = Cursors.WaitCursor;
                Server server = (Server)Activator.GetObject(
                    typeof(Server),
                    "tcp://localhost:8085/ChatServer");
                if (server == null)
                {
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("could not locate server");
                    return;
                }
                else
                    try
                    {
                        spmd.ClientNames = server.ClientNames;
                        this.Cursor = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show("an error occurred: " + ex.Message);
                        return;
                    }

                if (spmd.ShowDialog() == DialogResult.OK)
                {
                    this.Cursor = Cursors.WaitCursor;
                    try
                    {
                        server.PostPrivateMessage(this.client,  spmd.ClientName, spmd.MessageText);
                        this.Cursor = Cursors.Default;
                    }
                    catch (Exception ex)
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show("an error occurred: " + ex.Message);
                        return;
                    }
                }
            }
        }