示例#1
0
        public static void AddClient(string name, IPEndPoint remoteIP)
        {
            s_singleton.Invoke(new DoAction(delegate
            {
                IPAddress addr = remoteIP.Address;
                int port       = remoteIP.Port;

                UserInfo user = UserInfoManager.FindUser(remoteIP);
                if (user == null)
                {
                    user = new UserInfo(new IPEndPoint(addr, port), name);
                    UserInfoManager.AddUser(user);

                    GroupInfo[] groups = GroupInfoManager.GetGroupArray();
                    foreach (GroupInfo grp in groups)
                    {
                        OutgoingPackagePool.AddFirst(NetPackageGenerater.FindGroupUser(grp.Key, remoteIP));
                    }
                }
                else if (user.Username != name)
                {
                    user.Username = name;
                    s_singleton.m_users.UpdateUserName(user);
                }

                user.IsAlive = true;
                s_singleton.m_users.AddUser(user);
            }));
        }
示例#2
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            try
            {
                UserInfo us = new UserInfo();
                us.Username  = txtUserName.Text;
                us.Password  = txtPassword.Text;
                us.Email     = txtEmail.Text;
                us.Telephone = txtPhone.Text;
                int i = UserInfoManager.AddUser(us);

                if (i == 1)
                {
                    Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('注册成功!');</script>");
                }
            }
            catch (Exception)
            {
                Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('用户名重复,注册失败!');</script>");

                //Response.Write("错误原因:" + ex.Message);
            }
        }
    }