示例#1
0
        private void BtnCreateGroup_Click(object sender, EventArgs e)
        {
            string groupName = this.txtGroupName.Text.Trim();

            //验证输入的用户名是否为空
            if (groupName == null || groupName == string.Empty)
            {
                MessageBox.Show("请输入要创建群的名称!");
                return;
            }

            WebServiceMessage.WSMessage wsm = new WebServiceMessage.WSMessage();

            //判断要创建的群是否存在
            if (wsm.IsExistTheGroup(groupName) == true)
            {
                MessageBox.Show("该群已经存在");
            }
            else
            {
                //创建群
                wsm.CreateGroup(currentUsername, groupName);
                this.Close();
            }
        }
示例#2
0
        private void btnJoinGroup_Click(object sender, EventArgs e)
        {
            string GroupName = this.txtGroupName.Text.Trim();

            if (GroupName == null || GroupName == string.Empty)
            {
                MessageBox.Show("请输入要请求的群名称!");
                return;
            }

            WebServiceMessage.WSMessage wsm = new WebServiceMessage.WSMessage();
            //判断用户是否存在
            bool isExist = wsm.IsExistTheGroup(GroupName);

            if (!isExist)
            {
                MessageBox.Show("该群不存在");
                return;
            }

            ///////要添加一个避免重复加入群的判断

            //添加群,如果已经在群中跑出异常
            try
            {
                wsm.JoinGroup(currentUsername, GroupName);
            }
            catch
            {
                MessageBox.Show("不能重复加群");
            }

            this.Close();
        }