コード例 #1
0
ファイル: UIRegist.cs プロジェクト: zd304/ProjectD
 public void OnClickRegist()
 {
     Operation.UserInfo userInfo = new Operation.UserInfo();
     userInfo.username = username.text;
     userInfo.password = password.text;
     PhotonEngine.Instance.DoRequest <Operation.UserInfo>(Operation.OperationCode.Regist, userInfo);
 }
コード例 #2
0
ファイル: LoginHandler.cs プロジェクト: zd304/ProjectD
        public override void OnOperateRequest(byte[] bytes, ClientPeer peer, SendParameters sendParameters)
        {
            Operation.UserInfo userInfo = PackageHelper.Desirialize <Operation.UserInfo>(bytes);
            Model.UserInfo     dbUser   = UserManager.GetByUserName(userInfo.username);

            if (dbUser == null)
            {
                return;
            }

            OperationResponse response = new OperationResponse((byte)OperationCode.Login);

            if (dbUser.Password == userInfo.password)
            {
                response.ReturnCode = (short)ReturnCode.Success;
            }
            else
            {
                response.ReturnCode = (short)ReturnCode.Failed;
            }
            LoginSuccessResponse obj = new LoginSuccessResponse();

            obj.userName = userInfo.username;
            PackageHelper.SetData(response, PackageHelper.Serialize <LoginSuccessResponse>(obj));
            peer.SendOperationResponse(response, sendParameters);

            GameApplication application = GameApplication.Instance as GameApplication;

            if (application != null)
            {
                application.AddClientInfo(peer as GameClientPeer, userInfo.username);
            }
        }
コード例 #3
0
        public override void OnOperateRequest(byte[] bytes, ClientPeer peer, SendParameters sendParameters)
        {
            Operation.UserInfo userInfo = PackageHelper.Desirialize <Operation.UserInfo>(bytes);
            Model.UserInfo     dbUser   = UserManager.GetByUserName(userInfo.username);

            OperationResponse response = new OperationResponse((byte)OperationCode.Regist);

            if (dbUser != null)
            {
                response.ReturnCode = (short)ReturnCode.Failed;
            }
            else
            {
                dbUser = new Model.UserInfo()
                {
                    UserName = userInfo.username, Password = userInfo.password, RegisterDate = System.DateTime.Now
                };
                UserManager.Add(dbUser);
                response.ReturnCode = (short)ReturnCode.Success;
            }
            peer.SendOperationResponse(response, sendParameters);
        }