Пример #1
0
        public void VerifyUserTest()
        {
            IUserDAO userDao = new IUserDAOImpl();
            bool     result  = userDao.Verify(new Users("falcon", MD5Util.GetMD5("123456")));

            Assert.AreEqual(true, result);
        }
Пример #2
0
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters,
                                                ClientPeer clientPeer)
        {
            Dictionary <byte, object> data = operationRequest.Parameters;
            string            username     = DictUtil.GetValue(data, (byte)ParameterCode.Username) as string;
            string            password     = DictUtil.GetValue(data, (byte)ParameterCode.Password) as string;
            IUserDAO          dao          = new IUserDAOImpl();
            Users             u            = new Users(username, password);
            OperationResponse resp         = new OperationResponse(operationRequest.OperationCode);

            resp.ReturnCode = (short)(dao.Register(u) ? ReturnCode.RegisterSuccess : ReturnCode.RegisterFailed);
            clientPeer.SendOperationResponse(resp, sendParameters);
        }
Пример #3
0
        public override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters,
                                                ClientPeer clientPeer)
        {
            Dictionary <byte, object> data = operationRequest.Parameters;
            string            username     = DictUtil.GetValue(data, (byte)ParameterCode.Username) as string;
            string            password     = DictUtil.GetValue(data, (byte)ParameterCode.Password) as string;
            IUserDAO          dao          = new IUserDAOImpl();
            Users             u            = new Users(username, password);
            OperationResponse resp         = new OperationResponse(operationRequest.OperationCode);

            resp.ReturnCode = (short)(dao.Verify(u) ? ReturnCode.LoginSuccess : ReturnCode.LoginFailed);
            if (resp.ReturnCode == (short)ReturnCode.LoginSuccess)
            {
                MyClientPeer peer = clientPeer as MyClientPeer;
                if (peer != null)
                {
                    peer.username = username;
                }
            }

            clientPeer.SendOperationResponse(resp, sendParameters);
        }