예제 #1
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="clientPeer"></param>
        /// <param name="acc"></param>
        /// <param name="pwd"></param>
        public void Login(ClientPeer clientPeer, string acc, string pwd)
        {
            SingleExcute.Instance.Excute(() =>
            {
                if (!accountCache.IsExit(acc))
                {
                    //账号不存在
                    clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "账号不存在");
                    return;
                }
                if (accountCache.IsOnline(acc))
                {
                    //账号在线
                    clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "账号在线");
                    return;
                }

                if (!accountCache.IsMactch(acc, pwd))
                {
                    //账号密码不匹配
                    clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "密码错误");
                    return;
                }

                accountCache.Online(acc, clientPeer);
                clientPeer.Send(OpCode.ACCOUNT, AccountSubCode.LOGIN_SRES, "登录成功");
            });
        }