Пример #1
0
        }     // W_AddFrd

        /// <summary>
        /// 单击添加按钮
        /// </summary>
        /// <param name="sender">the sender</param>
        /// <param name="e">the e</param>
        private void btn_add_Click(object sender, EventArgs e)
        {
            // 将要被添加的用户名
            string destName = cmBox_frdList.SelectedItem.ToString();

            // 调用网络服务添加好友
            addFrd.addFrd(userName, destName);

            Thread.Sleep(500);

            User currentUser = User.GetInstance();

            CallBackFunc.noChatSendData("addfrd", userName, destName, currentUser.socket);

            this.DialogResult = DialogResult.OK;
        } // btn_add_Click
Пример #2
0
        }     // findAddMsg

        /// <summary>
        /// 单击退出按钮
        /// </summary>
        /// <param name="sender"> the sender</param>
        /// <param name="e"> the e</param>
        private void btn_exit_Click(object sender, EventArgs e)
        {
            IMSLogStateChangeClient IsLog = new IMSLogStateChangeClient();
            string loginResault           = IsLog.changeLogState(userName, userPwd, true);
            User   currentUser            = User.GetInstance();

            try
            {
                if (loginResault == "1")
                {
                    // 断开连接
                    if (currentUser.socket == null)
                    {
                        return;
                    }
                    if (!currentUser.socket.Connected)
                    {
                        return;
                    }
                    CallBackFunc.noChatSendData("logout", userName, "", currentUser.socket);
                    Thread.Sleep(2000);
                    SocketHandler.ShutDownConn(currentUser.socket);
                    MessageBox.Show("成功退出");
                    Application.Exit();
                } // if
                else if (loginResault == "0")
                {
                    MessageBox.Show("未登录,无法退出");
                }
                else
                {
                    MessageBox.Show("用户名或密码错误");
                } // else
            }     // try
            catch (System.Exception ex)
            {
                // the last client will be wrong when exit
                Application.Exit();
            }
        } // btn_exit_Click