private void Register(ClientPeer client, string account, string password) { SingleExecute.Instance.Execute(() => { if (accountCache.IsExist(account)) { //账号已经存在 client.StartSend(OpCode.ACCOUNT, AccountCode.REGISTER_SRES, "账号已经存在"); Console.WriteLine("账号已经存在..."); return; } if (string.IsNullOrEmpty(account)) { //表示账号输入不合法 client.StartSend(OpCode.ACCOUNT, AccountCode.REGISTER_SRES, "账号输入不合法"); Console.WriteLine("账号输入不合法..."); return; } //if (string.IsNullOrEmpty(password) || password.Length <= 4 || password.Length >= 16) //{ // //密码不合法 // client.StartSend(OpCode.ACCOUNT, AccountCode.REGISTER_SRES, "密码输入不合法"); // Console.WriteLine("密码输入不合法..."); // return; //} //可以注册了 accountCache.Creat(account, password); client.StartSend(OpCode.ACCOUNT, AccountCode.REGISTER_SRES, "注册成功"); Console.WriteLine("注册成功..."); }); }
/// <summary> /// 注册 /// </summary> /// <param name="client"></param> /// <param name="account"></param> /// <param name="password"></param> private void regist(ClientPeer client, string account, string password) { SingleExecute.Instance.Execute(() => { if (accountCache.IsExist(account)) { //表示账号已经存在 //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "账号已经存在"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, -1); return; } if (string.IsNullOrEmpty(account)) { //表示账号输入不合法 //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "账号输入不合法"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, -2); return; } if (string.IsNullOrEmpty(password) || password.Length < 4 || password.Length > 16) { //表示密码不合法 //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "密码不合法"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, -3); return; } //可以注册了 accountCache.Creat(account, password); //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "注册成功"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, 0); }); }
/// <summary> /// 注册 /// </summary> /// <param name="client"></param> /// <param name="account"></param> /// <param name="password"></param> private void Regist(ClientPeer client, string account, string password) { SingleExecute.Instance.Execute(() => { if (accountCache.IsExist(account)) { //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "账号已存在"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, -1); return; //账号已存在 } if (string.IsNullOrEmpty(account)) { // client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "账号为空"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, -2); return;//账号为空 } if (string.IsNullOrEmpty(password)) { //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "密码不合法"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, -3); return;//密码不合法 } accountCache.Creat(account, password); //client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, "注册成功"); client.Send(OpCode.ACCOUNT, AccountCode.REGIST_SRES, 0); }); }