You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

98 lines
3.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using Sog.Log;
using ProtoCSStruct;
namespace Friend
{
public static class MailSvc
{
private static void OnFriendMailOpRes(SSMailOpRes res)
{
// world暂时只支持发送邮件操作
if (res.OpType != (int) MailOpType.Insert)
{
TraceLog.Debug("MailSvc.OnWorldSendMailRes invalid mailOp");
return;
}
TraceLog.Trace("MailSvc.OnWorldSendMailRes uniqueId {0} uid {1}, mail {2}",
res.UniqueID, res.Mail.Uid, res.Mail.MailID);
if (res.UniqueID != 0)
{
WaitAckStructRequestSender.Instance.OnReceiveSuccess(res.UniqueID);
}
// 发送失败时,打日志,220201表示邮件已经存在
if (res.Ret != 0 && res.Ret != 220201)
{
TraceLog.Error("MailSvc.OnWorldSendMailRes failed uid {0}, mail {1}", res.Mail.Uid, res.Mail.MailID);
}
CommBillLogUtils.LogMailOpRet(res.ClientOpUid, ref res.Mail, res.OpType, res.Ret);
}
public static void OnMailOpRes(uint remoteAppID, StructPacket packet)
{
ref SSMailOpRes res = ref packet.GetMessage<SSMailOpRes>();
// Friend发送的邮件,好友服务器只支持这种形式
if (res.AckGameServerID == FriendServerUtils.GetAppID())
{
OnFriendMailOpRes(res);
}
//新增邮件需要通知邮件的主人,如果他在线的话
//取附件和删除操作肯定是自己发起的,上面的AckGameServerID肯定不为空,可以走到(gm指令发起的不一定走到,所以都发一下)
if (/*res.OpType == (int)MailOpType.Insert
&&*/ res.Ret == 0
&& res.ClientOpUid != res.Mail.Uid)
{
PlayerInfoFriend player = FriendServerUtils.GetPlayerTableOp().GetPlayerInfo(res.Mail.Uid);
//不在线正常的很
if (player == null || player.WorldServerID == 0)
{
TraceLog.Trace("MailSvc.OnMailOpRes can not find mail owner player uid {0}", res.Mail.Uid);
return;
}
res.ClientOpUid = res.Mail.Uid;
//清空这个uniqueID,只是通知而已
res.UniqueID = 0;
TraceLog.Trace("MailSvc.OnMailOpRes notify mail owner player uid {0} insert new mail {1}", res.Mail.Uid, res.Mail.MailID);
FriendServerUtils.GetPacketSender().SendToServerByID(player.WorldServerID, (int)SSGameMsgID.MailOpRes,ref res, res.ClientOpUid);
}
}
public static void SendMail(DBMail mail)
{
SSMailOpReq req = new SSMailOpReq();
req.OpType = (int)MailOpType.Insert;
req.AckGameServerID = FriendServerUtils.GetAppID();
req.UniqueID = WaitAckStructRequestSender.Instance.GeneratorUniqueID();
mail.InsertUniqueID = req.UniqueID;
req.Mail = new DBMail();
TraceLog.Trace("MailSvc.SendMail uniqueId {0} mailId {1} uid {2}", req.UniqueID, mail.MailID, mail.Uid);
uint mailServerID = FriendServerUtils.GetPacketSender().GetMailServerID();
//uint dbServerID = FriendSvrIDUtils.GetDBServerID(mail.Uid);
WaitAckStructRequestSender.Instance.BeginSendNeedResend(req.UniqueID, mailServerID, (int)SSGameMsgID.MailOpReq,ref req, 0);
CommBillLogUtils.LogMailOpBegin(mail.Uid, mail, (int)MailOpType.Insert);
}
}
}