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); }
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); } }
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); }