/// <summary> /// 请求更新邮件信息 /// </summary> /// <param name="pID">P I.</param> /// <param name="msg">Message.</param> /// <param name="action">Action.</param> public void sendMsg(LobbyProtocol pID, msgReqUpdateEmail msg, Action <Message> action) { JsonObject jsonMsg = new JsonObject(); jsonMsg.Add("type", (int)msg.type); jsonMsg.Add("awardEmailId", msg.awardEmailId); sendMsg(pID, jsonMsg, action); }
public void onEventReqUpdateEmail(object data) { LobbyEvent.sV2C_ReqUpdateEmail re = (LobbyEvent.sV2C_ReqUpdateEmail)data; msgReqUpdateEmail msg = new msgReqUpdateEmail(); msg.type = re.type; msg.awardEmailId = re.id; ProtocolManager.getInstance().sendMsg(LobbyProtocol.P_LOBBY_REQ_UPDATE_EMAIL, msg, OnRespUpdateEmail); ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_LOADING_ANI, true); }
void OnRespUpdateEmail(Message msg) { ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_LOADING_ANI, false); msgReqUpdateEmail resp = msgReqUpdateEmail.deserialize(msg); int find = -1; for (int i = 0; i < Lobby.Lobby.privateMsgList.Count; i++) { if (Lobby.Lobby.privateMsgList [i].id == resp.awardEmailId) { find = i; break; } } if (find == -1) { //邮件不存在 return; } LobbyEvent.PrivateMsg psm; psm.author = Lobby.Lobby.privateMsgList [find].author; psm.content = Lobby.Lobby.privateMsgList [find].content; psm.end_time = Lobby.Lobby.privateMsgList [find].end_time; psm.has_read = Lobby.Lobby.privateMsgList [find].has_read; psm.id = Lobby.Lobby.privateMsgList [find].id; psm.send_time = Lobby.Lobby.privateMsgList [find].send_time; psm.title = Lobby.Lobby.privateMsgList [find].title; if (resp.type == CommonDefine.eUpdateEmailType.READ) { //更新邮件缓存列表 psm.has_read = 1; Lobby.Lobby.privateMsgList [find] = psm; checkIfHasUnReadEmail(); } else if (resp.type == CommonDefine.eUpdateEmailType.DEL) { //删除 Lobby.Lobby.privateMsgList.RemoveAt(find); checkIfHasUnReadEmail(); } else if (resp.type == CommonDefine.eUpdateEmailType.GET_AWARD) { CommonUtil.EmailContent ec = CommonUtil.EmailContent.deserialize(Lobby.Lobby.privateMsgList[find].content); if (ec.hasGottenAward) { //已经领取过奖励了 CommonUtil.Util.showDialog("温馨提示", "您已经领取过奖励了 :)"); return; } else { ec.hasGottenAward = true; psm.content = CommonUtil.EmailContent.serialize(ec); Lobby.Lobby.privateMsgList [find] = psm; // 奖励需要同时更新 用户金币以及包裹信息 if (ec.type == CommonUtil.EmailContent.AWARD_TYPE.GOLD) { Account.updateUserGold(ec.awardCnt); //已经可以更新用户相关界面信息 onEventShowUserInfo(null); } else if (ec.type == CommonUtil.EmailContent.AWARD_TYPE.PROP) { //重新请求一遍 msgReqPackageList package = new msgReqPackageList(); package.game = GameType.GAME_LIANQI; ProtocolManager.getInstance().sendMsg(LobbyProtocol.P_LOBBY_REQ_PACKAGE_LIST, package, OnRespPackageList); } } } LobbyEvent.sV2C_ReqUpdateEmail re; re.id = resp.awardEmailId; re.type = resp.type; LobbyEvent.EM().InvokeEvent(LobbyEvent.EVENT.SHOW_UPDATE_EMAIL_RESULT, (object)re); }