/// <summary> /// 登录处理 /// </summary> /// <param name="acc"></param> /// <param name="pwd"></param> private void OnLogin(MobaClient client, string acc, string pwd) { //无效检查 if (acc == null || pwd == null) { return; } if (cache.IsOnline(acc)) { this.Send(client, OpCode.AccountCode, OpAccount.Login, -1, "玩家在线"); return; } //验证账号密码是否合法 bool res = cache.Match(acc, pwd); if (res == true) { cache.OnLine(acc, client); this.Send(client, OpCode.AccountCode, OpAccount.Login, 0, "登录成功"); } else { this.Send(client, OpCode.AccountCode, OpAccount.Login, -2, "账号密码错误"); } }
private void Login(ClientPeer client, string account, string password) { SingleExecute.Instance.Execute(() => { if (!accountCache.IsExist(account)) { client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -1); Console.WriteLine(string.Format("Error:Account doesn't exist!")); return; } if (!accountCache.IsMatch(account, password)) { client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -2); Console.WriteLine(string.Format("Error:Password dosen't match!")); return; } if (accountCache.IsOnline(account)) { client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -3); Console.WriteLine(string.Format("Error:Account is online!")); return; } accountCache.OnLine(client, account); client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, 0); Console.WriteLine(string.Format("Sign in Successfully!")); }); }
private void Login(ClientPeer client, string account, string password) { SingleExecute.Instance.Execute(() => { if (accountCache.IsExist(account) == false) { //账号不存在 //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号错误"); client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -1); return; } if (accountCache.IsMatch(account, password) == false) { //账号密码不匹配 //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号密码不匹配"); client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -2); return; } if (accountCache.IsOnline(account)) { //账号已经登录 //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "账号已登录"); client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, -3); return; } accountCache.OnLine(account, client); //client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, "登录成功"); client.Send(OpCode.ACCOUNT, AccountCode.LOGIN, 0); }); }