private void OnLoginResponse(byte moduleCode, byte opCode, ExitGames.Client.Photon.OperationResponse response) { string json = response.Parameters[1].ToString(); LoginResultVo vo = JsonReader.Deserialize <LoginResultVo>(json); if (vo.result == 1) { UIManager.GetInstance().SwitchScene("SelectServerUI"); Global.Info("登录成功!"); } else { Global.Info("登录失败!"); } }
public override void Parse(UserClient user, byte moduleCode, byte operationCode, OperationRequest operationRequest, SendParameters sendParameters) { //获取用户名和密码 string username = operationRequest.Parameters[(byte)1].ToString(); string userpwd = operationRequest.Parameters[(byte)2].ToString(); AccountAction aa = new AccountAction(); Account ac = aa.CheckLogin(username, userpwd); //构建消息 S2CMessage msg = new S2CMessage((byte)Module.Login, (byte)LoginOperation.UserLogin); Global.Info("向客户端发送信息" + msg.moudleCode + "," + msg.operationCode); LoginResultVo lro = new LoginResultVo(); //登录成功 if (ac != null) { lro.result = 1; lro.info = "登录成功"; } else { lro.result = 0; lro.info = "用户名或密码错误!"; } msg.Add((byte)1, JsonMapper.ToJson(lro)); //发送反馈 OperationResponse response = new OperationResponse((byte)moduleCode, msg); user.SendOperationResponse(response, sendParameters); }