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.
 
 
 
 
 
 

735 lines
30 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
using ProtoCSStruct;
using Sog.Service;
using Sog.Gate;
namespace Chat
{
/// <summary>
/// 聊天
/// </summary>
public static class ChatSvc
{
private const uint TrumpetItemId = 70017;
private const int WorldChatTimeSpan = 5000; //世界频道聊天间隔
private const int WorldChatListMaxNum = 500;
public static void OnPlayerDisconnected(PlayerOnChat player)
{
}
public static int ConsumeMagicEmotion(PlayerOnChat player, long ChatMagicChip)
{
return 0;
}
public static void ChatResFillPlayerInfo(PlayerOnChat player, ref CSChatRes chatRes)
{
chatRes.Uid = player.UserID;
chatRes.Nick.SetString(player.Nick);
chatRes.Icon.SetString(player.Icon);
chatRes.IconFrameId = player.iconFrameId;
chatRes.Gender = player.Gender;
chatRes.RealmId = player.RealmID;
chatRes.Level = player.roleBase.Level;
string realmName = "";
foreach (RealmBriefInfo info in ChatServerUtils.GetChatServerData().m_allRealmMap.Values)
{
if (info.realmId == player.RealmID)
{
realmName = info.realmName;
break;
}
}
chatRes.RealmName.SetString(realmName);
}
public static int OnChatConsumeReq(uint serverId, StructPacket packet)
{
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(packet.ObjectID);
if (player == null)
{
TraceLog.Error("ChatSvc.OnChatConsumeReq no player object uid {0}", packet.ObjectID);
return -1;
}
ref var req = ref packet.GetMessage<SSChatConsumeReq>();
var uid = packet.ObjectID;
if (ConsumeMagicEmotion(player, req.ConsumeChip) != 0)
{
TraceLog.Error("ChatSvc.OnChatConsumeReq player chip not enough", packet.ObjectID);
var failedRes = new CSChatRes();
failedRes.Ret = -1;
PlayerPacketSender.SendToPlayer(player, (int)CSGameMsgID.ChatRes, ref failedRes);
return -1;
}
var res = new SSChatConsumeRes();
res.Ret = 0;
res.Chat = req.Chat;
ChatServerUtils.GetPacketSender().SendToServerByID(serverId, (int)SSGameMsgID.ChatConsumeRes, ref res, uid);
return 0;
}
//客户端登录请求
public static void ProcessClientChatLoginReq(PlayerOnChat player, StructPacket packet)
{
ref CSChatLoginReq csReq = ref packet.GetMessage<CSChatLoginReq>();
if (csReq.PlayerUid == 0)
{
TraceLog.Error("ChatSvc.ProcessClientChatLoginReq invalid uid is zero");
return;
}
player.UserID = csReq.PlayerUid;
player.RealmID = csReq.RealmId;
player.LogicWorldID = ChatServerUtils.GetLogicWorldId(player.RealmID);
// 将 player session 加入 uid
ChatServerUtils.GetPlayerTableOp().AddPlayerUid(player);
//通知下world下,检查下玩家是不是登录了,
ChatServerUtils.GetPacketSender().SendToWorldServer<CSChatLoginReq>(packet, player.UserID);
return;
}
//world服务器验证登录返回
public static void ProcessServerChatLoginReq(uint serverID, StructPacket packet)
{
ref CSChatLoginReq csReq = ref packet.GetMessage<CSChatLoginReq>();
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(csReq.PlayerUid);
if (player == null)
{
TraceLog.Error("ChatSvc.ProcessServerChatLoginReq no player object uid {0}", packet.ObjectID);
return;
}
if (csReq.NeedSycClient)
{
CSChatLoginRes res = new CSChatLoginRes();
res.Uid = player.UserID;
res.Ret = csReq.Ret;
PlayerPacketSender.SendToPlayer(player, (int)CSGameMsgID.ChatloginRes, ref res);
}
//连接验证回应
if (csReq.Ret == 0)
{
player.Lang = csReq.Lang.ToString();
player.roleBase.CopyFrom(ref csReq.RoleBase);
player.sysData.CopyFrom(ref csReq.SysData);
player.extData.CopyFrom(ref csReq.ExtData);
player.RealmID = csReq.RealmId;
player.LogicWorldID = ChatServerUtils.GetLogicWorldId(player.RealmID);
player.LoginToken = csReq.LoginToken;
player.Nick = csReq.RoleBase.Nick.GetString();
player.Icon = csReq.RoleBase.Icon.GetString();
player.Gender = csReq.RoleBase.Gender;
player.GagChatEndTime = csReq.EnableMsgTime;
DealCacheChatMsg(player);
}
else
{
player.UserID = 0;
//失败了,要断开chat的连接了
GateService.NotifyGateServerDisconnect(ChatServerUtils.GetApp(), player.GateServerID, player.SessionID);
}
}
//world服务器同步数据
public static void OnSaveRoleNotify(uint serverID, StructPacket packet)
{
ref SSSaveRoleNotify req = ref packet.GetMessage<SSSaveRoleNotify>();
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(req.RoleBase.Uid);
if (player == null)
{
TraceLog.Trace("ChatSvc.OnSaveRoleNotify no player object uid {0}", packet.ObjectID);
return;
}
TraceLog.Trace("ChatSvc.OnSaveRoleNotify uid {0} oldChatBlackCount {1} oldChatBlackVer {2} newChatBlackCount {3} newChatBlackVer {4}", packet.ObjectID, player.extData.ChatBlackList.Count, player.extData.ChatBlackVer, req.ExtData.ChatBlackList.Count, req.ExtData.ChatBlackVer);
player.extData.CopyFrom(ref req.ExtData);
}
/// <summary>
/// 更新系统公告
/// </summary>
/// <param name="serverID"></param>
/// <param name="packet"></param>
public static void OnUpdateSysNotice(uint serverID, StructPacket packet)
{
ref SSSysNotice req = ref packet.GetMessage<SSSysNotice>();
uint id = (uint)req.Id;
uint noticeId = (uint)req.NoticeId;
//var oldnotice = ChatServerUtils.GetChatServerData().m_sysNoticeList.Find(f => f.m_desc.id == id);
//var exist = oldnotice != null && oldnotice.m_desc.id != 0;
// ? 是否需要判断
//var diffLanguageNotice = ChatServerUtils.GetChatServerData().m_sysNoticeList.Find(f => f.noticeId == noticeId);
//var isSame = diffLanguageNotice != null && diffLanguageNotice.m_desc.id != 0;
SysNoticeSvc.AddOneSysNotice(ref req);
//更新公告的时候不要广播了,没啥用,2份代码还容易出问题
#if false
var tempobj = ChatServerUtils.GetChatServerData().m_sysNoticeList.Find(f => f.m_desc.id == id);
//如果已经存在则更新时间必须大于历史更新时间
if ((exist && req.Uptime > oldnotice.m_upTime) || !exist || !isSame)
{
CSQuerySysUpNoticeRes res = new CSQuerySysUpNoticeRes();
res.Noticetype = req.Popup == 0 ? NoticeType.Click : NoticeType.Popup;
res.Uppotice = new CSSysNotice();
//只有公告显示时才下发具体内容
if (req.State == 1)
{
res.Uppotice.Content = req.Content;
res.Uppotice.Icon = req.Icon;
res.Uppotice.Jump = req.Jump;
res.Uppotice.Pic = req.Pic;
res.Uppotice.Seq = req.Id;
//res.Uppotice.StartTime = req.StartTime;
//res.Uppotice.EndTime = req.EndTime;
res.Uppotice.Title = req.Title;
res.Uppotice.Showtimetext = req.Showtimetext;
res.Uppotice.Sort = req.Sort;
res.Uppotice.Link = req.Link;
res.Uppotice.Dungeonid = req.Dungeonid;
res.Uppotice.Giftbagcustoms = req.Giftbagcustoms;
res.Uppotice.JumpParam = req.JumpParam;
}
res.Uppotice.IsShow = req.State == 1;
res.Uppotice.Id = req.Id;
foreach (var Player in ChatServerUtils.GetPlayerTable().m_sessionsTable)
{
res.Uppotice.IsShow = req.State == 1;
if (string.IsNullOrEmpty(Player.Value.Lang))
{
continue;
}
if (req.Language.GetString().ToLower() != Player.Value.Lang.ToLower())
{
// 如果所用语言不相同,不发送
continue;
}
var Checkres = SysNoticeSvc.CheckSysNotice(id, Player.Value.RealmID);
if (Checkres.Item1)
{
res.Uppotice.StartTime = Checkres.Item2;
res.Uppotice.EndTime = Checkres.Item3;
}
//公告过期了也设置隐藏
else
{
res.Uppotice.IsShow = false;
}
PlayerPacketSender.SendToPlayer(Player.Key, (int)CSGameMsgID.QueryUpsysnotice, ref res);
}
}
#endif
}
/// <summary>
/// 删除系统公告
/// </summary>
/// <param name="serverID"></param>
/// <param name="packet"></param>
public static void OnDelSysNotice(uint serverID, StructPacket packet)
{
var del = packet.GetMessage<SSSysNoticeDel>();
var obj = ChatServerUtils.GetChatServerData().m_sysNoticeList.Find(f => f.notice.Id == del.Id);
if (obj != null && obj.notice.Id != 0)
{
ChatServerUtils.GetChatServerData().m_sysNoticeList.Remove(obj);
//CSQuerySysUpNoticeRes res = new CSQuerySysUpNoticeRes();
//res.Uppotice = new CSSysNotice();
//res.Uppotice.Id = del.Id;
//res.Uppotice.IsShow = false;
//res.Noticetype = del.Noticetype;
//foreach (var sessions in ChatServerUtils.GetPlayerTable().m_sessionsTable.Keys)
//{
// PlayerPacketSender.SendToPlayer(sessions, (int)CSGameMsgID.QueryUpsysnotice, ref res);
//}
}
}
//更新展示信息
public static void OnPlayerShowInfoUpdate(uint serverID, StructPacket packet)
{
ref SSPlayerShowInfoUpdate req = ref packet.GetMessage<SSPlayerShowInfoUpdate>();
long uid = req.Uid;
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(uid);
if (player == null)
{
TraceLog.Trace("ChatSvc.OnPlayerShowInfoUpdate not find role uid {0}", uid);
return;
}
player.roleBase.Nick.CopyFrom(ref req.Nick);
player.roleBase.Icon.CopyFrom(ref req.Icon);
player.roleBase.Gender = req.Gender;
player.roleBase.Level = req.Level;
player.Nick = req.Nick.GetString();
player.Icon = req.Icon.GetString();
player.Gender = req.Gender;
player.sysData.IconFrameId = req.IconFrameId;
player.iconFrameId = req.IconFrameId;
TraceLog.Trace("ChatSvc.OnPlayerShowInfoUpdate uid {0}", uid);
}
public static void ProcessChatReq(PlayerOnChat player, StructPacket packet)
{
ref CSChatReq csReq = ref packet.GetMessage<CSChatReq>();
if (csReq.Uid == 0)
{
TraceLog.Error("ChatSvc.ProcessChatReq invalid uid is zero");
return;
}
if (player.UserID == 0 || csReq.Uid != player.UserID)
{
TraceLog.Error("ChatSvc.ProcessChatReq invalid uid {0}:{1}", csReq.Uid, player.UserID);
return;
}
if (player.LoginToken <= 0 || csReq.CheckToken != player.LoginToken)
{
TraceLog.Error("ChatSvc.ProcessChatReq invalid CheckToken {0}:{1}:{2}", player.UserID, csReq.CheckToken, player.LoginToken);
return;
}
//被禁言了
if (ChatServerUtils.GetTimeSecond() < player.GagChatEndTime)
{
TraceLog.Debug("ChatSvc.ProcessChatReq player uid {0} be forbidden chat, end time {1}"
, csReq.Uid, AppTime.ConvertUnixTimeToDateTime(player.GagChatEndTime * 1000));
CSChatRes res = new CSChatRes();
res.Uid = csReq.Uid;
res.Ret = (int)CSErrCode.ChatEnableMsg;
res.EnableMsgTime = player.GagChatEndTime;
PlayerPacketSender.SendToPlayer(player, (int)CSGameMsgID.ChatRes, ref res);
return;
}
string msgStr = csReq.Message.ToString();
//限制100个字符
if (csReq.Message.Length > 200)
{
csReq.Message.SetString(msgStr.Substring(0, 200));
}
TraceLog.Trace("ChatSvc.ProcessChatReq uid {0} chat:{1}", player.UserID, csReq.Message);
//特权表情(先废弃,看之后的方案)
//if (csReq.Type == (int)ChatType.PrivilegeEmoticon)
//{
//if (false == VipCardPrivilegeSvc.HaveEmoticonPrivilege(player))
// {
// TraceLog.Error("ChatSvc.ProcessChatReq player uid {0} HaveEmoticonPrivilege false"
// , csReq.Uid);
// return -5;
// }
//}
if (ChatServerUtils.GetServerConfig().isUseHeroSentiment == 1)
{
HeroSentimentSvc.OnHandleChatRealtimeValidate(player, ref csReq);
}
else
{
SendToChatMsg(player, ref csReq);
}
}
public static void SendToChatMsg(PlayerOnChat player, ref CSChatReq csReq)
{
if (csReq.ChatChannelType == ChatChannelType.Friend)
{
if (csReq.TargetUid == player.UserID)
{
TraceLog.Error("ChatSvc.SendToChatMsg player uid {0} chat self in friend channel", csReq.Uid);
return;
}
//给word去转发吧
//ChatServerUtils.GetPacketSender().SendToWorldServer<CSChatReq>(packet, player.UserID);
PlayerOnChat(player, ref csReq);
}
else if (csReq.ChatChannelType == ChatChannelType.World)
{
WorldChat(player, ref csReq);
}
else if (csReq.ChatChannelType == ChatChannelType.BigRealm)
{
BigRealmChat(player, ref csReq);
}
else
{
TraceLog.Error("ChatSvc.ProcessChatReq csReq.ChatChannelType {0} error Type", csReq.ChatChannelType);
return;
}
ChatBillLogUtils.LogChatReq(player.UserID, ref csReq);
return;
}
//只会受到好友服务器的回应,直接转给客户端
public static void OnChatRes(uint serverID, StructPacket packet)
{
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(packet.ObjectID);
if (player == null)
{
TraceLog.Error("ChatSvc.OnChatRes no player object uid {0}", packet.ObjectID);
return;
}
PlayerPacketSender.SendToPlayer<CSChatRes>(player, packet);
}
//客户端好友离线消息请求
public static void OnQueryChatDataReq(PlayerOnChat player, StructPacket packet)
{
if (player == null)
{
TraceLog.Error("ChatSvc.OnChatRes no player object uid {0}", packet.ObjectID);
return;
}
ref CSQueryChatDataReq csReq = ref packet.GetMessage<CSQueryChatDataReq>();
ChatServerUtils.GetPacketSender().SendToFriendServer<CSQueryChatDataReq>(packet, player.UserID);
}
public static void OnChannelCacheDataReq(PlayerOnChat player, StructPacket packet)
{
ref CSChannelCacheDataReq csReq = ref packet.GetMessage<CSChannelCacheDataReq>();
ChatCacheOp.OnGetChannelCacheData(player, csReq.ChatChannelType, csReq.ChannelParam, csReq.Seq);
}
public static void OnGagChatNotify(uint serverID, StructPacket packet)
{
ref var gagChatNotify = ref packet.GetMessage<CSGagChatNotify>();
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(packet.ObjectID);
if (player == null)
{
TraceLog.Trace("SysHandler.OnGagChatNotify uid {0} not in memory", packet.ObjectID);
if (ChatServerUtils.GetServerConfig().isUseHeroSentiment == 1 && !gagChatNotify.OpSource.Equals("hero")) //不是hero舆情系统处理的,都需要上报封禁数据
{
HeroSentimentSvc.OnHandleChatBan(packet.ObjectID, player, ref gagChatNotify);
}
return;
}
player.GagChatEndTime = gagChatNotify.GagEndTime;
if (ChatServerUtils.GetServerConfig().isUseHeroSentiment == 1 && !gagChatNotify.OpSource.Equals("hero")) //不是hero舆情系统处理的,都需要上报封禁数据
{
HeroSentimentSvc.OnHandleChatBan(packet.ObjectID, player, ref gagChatNotify);
}
PlayerPacketSender.SendToPlayer<CSGagChatNotify>(player, packet);
}
public static void OnGmSetFreezeTimeRes(uint serverID, StructPacket packet)
{
ref var freezeTimeRes = ref packet.GetMessage<SSGMSetFreezeTimeRes>();
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(packet.ObjectID);
if (ChatServerUtils.GetServerConfig().isUseHeroSentiment == 1 && !freezeTimeRes.OpSource.Equals("hero")) //不是hero舆情系统处理的,都需要上报封禁数据
{
HeroSentimentSvc.OnHandleSetFreezeTime(packet.ObjectID, player, ref freezeTimeRes);
}
}
private static void PlayerOnChat(PlayerOnChat player, ref CSChatReq csReq)
{
TraceLog.Trace("ChatSvc.PlayerOnChat player uid {0} to target {1}", csReq.Uid, csReq.TargetUid);
ChatServerUtils.GetPacketSender().SendToFriendServer((int)CSGameMsgID.ChatReq, ref csReq, csReq.Uid);
}
private static void WorldChat(PlayerOnChat player, ref CSChatReq csReq)
{
TraceLog.Trace("ChatSvc.WorldChat player uid {0}", player.UserID);
csReq.ChannelParam = player.LogicWorldID;
var charServerData = ChatServerUtils.GetChatServerData();
long nowSecondMs = AppTime.GetNowSysMs();
CSChatRes res = new CSChatRes();
ChatResFillPlayerInfo(player, ref res);
res.ChatChannelType = csReq.ChatChannelType;
res.ChannelParam = csReq.ChannelParam;
res.SendTime = nowSecondMs;
res.ChatSeq = charServerData.GetChannalChatSeq(ChatChannelType.World, csReq.ChannelParam);
res.Ret = 0;
if (nowSecondMs - player.LastWorldChatTime < WorldChatTimeSpan)
{
TraceLog.Error("ChatSvc.WorldChat player uid {0} timespan limited LastWorldChatTime {1}", player.UserID, player.LastWorldChatTime);
res.Ret = (int)CSErrCode.ChatWorldChatCd;
PlayerPacketSender.SendToPlayer(player, (int)CSGameMsgID.ChatRes, ref res);
return;
}
res.Message = csReq.Message;
player.LastWorldChatTime = nowSecondMs;
//扣除道具和存数据库的之后需要从101,未知原因被废弃了(协议也没了)
TraceLog.Trace("ChatSvc.WorldChat player uid {0} broadcast to all", player.UserID);
PlayerPacketSender.BroadcastToGate(player, (int)CSGameMsgID.ChatRes, ref res);
ChatCacheOp.AddChatCache(ref res);
}
/*感觉这个查询可以用的,废弃了? 101有
public static void OnQueryWorldChatReq(PlayerSession playerSession, RequestPacket packet)
{
PlayerOnGame player = playerSession.Player;
if (player == null)
{
TraceLog.Error("ChatSvc.OnQueryWorldChatReq no player object uid {0}", playerSession.UserID);
return;
}
CSQueryWorldChatReq req = (CSQueryWorldChatReq)packet.Message;
ref GameServerGlobalData data = ref GameServerUtils.GetGameServerData().m_GameServerGlobalData;
CSQueryWorldChatRes res = new CSQueryWorldChatRes();
if(data.WorldChatData.TopRecord != null)
{
res.TopRecord = data.WorldChatData.TopRecord;
}
if(req.StartSeq == 0)
{
req.StartSeq = uint.MaxValue;
}
//一次最多10条
for(int i= data.WorldChatData.List.Count - 1; i >= 0; i--)
{
var record = data.WorldChatData.List[i];
if(record.Seq < req.StartSeq)
{
res.List.Add(record);
}
if(res.List.Count > 10)
{
break;
}
}
player.SendToClient((int)CSGameMsgID.QueryWorldChatRes, res);
}
*/
private static void BigRealmChat(PlayerOnChat player, ref CSChatReq csReq)
{
TraceLog.Trace("ChatSvc.BigRealmChat player uid {0}", player.UserID);
var bigRealmDict = ChatServerUtils.GetChatServerData().m_bigRealmDict;
if (!bigRealmDict.ContainsKey((int)csReq.ChannelParam) || !bigRealmDict[(int)csReq.ChannelParam].Contains(player.RealmID))
{
TraceLog.Error("ChatSvc.BigRealmChat player uid {0} error no in bigRealm {1} realmId {2}", player.UserID, csReq.ChannelParam, player.RealmID);
return;
}
var charServerData = ChatServerUtils.GetChatServerData();
long nowSecondMs = AppTime.GetNowSysMs();
CSChatRes res = new CSChatRes();
ChatResFillPlayerInfo(player, ref res);
res.Ret = 0;
res.ChatChannelType = csReq.ChatChannelType;
res.ChannelParam = csReq.ChannelParam;
res.SendTime = nowSecondMs;
res.ChatSeq = charServerData.GetChannalChatSeq(ChatChannelType.BigRealm, csReq.ChannelParam);
res.Message = csReq.Message;
TraceLog.Trace("ChatSvc.BigRealmChat player uid {0} broadcast to BigRealm:{1}", player.UserID, csReq.ChannelParam);
PlayerPacketSender.BroadcastToBigRealm(player, (int)CSGameMsgID.ChatRes, ref res);
ChatCacheOp.AddChatCache(ref res);
}
//处理离线消息
public static void DealCacheChatMsg(PlayerOnChat player)
{
//处理世界频道缓存
ChatCacheOp.OnGetChannelCacheData(player, ChatChannelType.World, player.LogicWorldID, 0);
int bigRealmId = ChatSvc.GetBigRealm(player.RealmID);
if (bigRealmId > 0)
{
ChatCacheOp.OnGetChannelCacheData(player, ChatChannelType.BigRealm, bigRealmId, 0);
}
//去好友服务器请求好友缓存
var req = new CSQueryChatDataReq();
ChatServerUtils.GetPacketSender().SendToFriendServer((int)CSGameMsgID.QueryChatDataReq, ref req, player.UserID);
}
//好友服务器离线消息返回
public static void OnQueryChatDataRes(StructPacket packet)
{
ref CSQueryChatDataRes csRes = ref packet.GetMessage<CSQueryChatDataRes>();
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(csRes.Uid);
if (player == null)
{
TraceLog.Error("ChatSvc.OnQueryChatDataRes play:{0} error", csRes.Uid);
return;
}
PlayerPacketSender.SendToPlayer<CSQueryChatDataRes>(player, packet);
}
public static void OnRecvPrivateChatNotify(StructPacket packet)
{
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(packet.ObjectID);
if (player == null)
{
TraceLog.Error("ChatSvc.OnRecvPrivateChatNotify play:{0} error", packet.ObjectID);
return;
}
PlayerPacketSender.SendToPlayer<CSRecvPrivateChatNotify>(player, packet);
}
public static void OnNoticeBackgroundsRes(StructPacket packet)
{
ref var res = ref packet.GetMessage<SSNoticeBackGroundsRes>();
if (res.PicList.Count == 0)
{
// 0 是正常现象
return;
}
var picDict = ChatServerUtils.GetChatServerData().m_noticeBackgrounds;
for (int i = 0; i < res.PicList.Count; i++)
{
string lang = res.PicList[i].Language.GetString();
string pic = res.PicList[i].Pic.GetString();
picDict[lang] = pic;
}
if (res.Uid != 0)
{
CSQuerySysNoticeImgRes playerRes = new CSQuerySysNoticeImgRes();
PlayerOnChat player = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChatByUID(res.Uid);
if (player == null)
{
TraceLog.Error("ChatSvc.OnNoticeBackgroundsRes play:{0} error", packet.ObjectID);
return;
}
playerRes.Pic.SetString("");
if (picDict.ContainsKey(player.Lang))
{
playerRes.Pic.SetString(picDict[player.Lang]);
}
playerRes.Lang.SetString(player.Lang);
PlayerPacketSender.SendToPlayer(player, (int)CSGameMsgID.QuerySysnoticeImgRes, ref playerRes);
}
}
public static int GetBigRealm(int realmId)
{
var allBigRealm = ChatServerUtils.GetChatServerData().m_bigRealmDict;
foreach (var it in allBigRealm)
{
if (it.Value.Contains(realmId))
{
return it.Key;
}
}
TraceLog.Error("ChatSvc.GetBigRealm error reaml {0} no bigrealmId", realmId);
return 0;
}
public static void OnCheckDirtyStringReq(uint serverID, StructPacket packet)
{
ref SSCheckDirtyStringReq req = ref packet.GetMessage<SSCheckDirtyStringReq>();
if (ChatServerUtils.GetServerConfig().isUseHeroSentiment == 1)
{
HeroSentimentSvc.OnHandleDirtyChatCheck(ref req);
}
else
{
SSCheckDirtyStringRes res = new SSCheckDirtyStringRes();
res.Result = 0;
res.Uid = req.Uid;
res.CheckSeq = req.CheckSeq;
res.NewContent.CopyFrom(ref req.Content);
ChatServerUtils.GetPacketSender().SendToServerByID(req.ServerId, (int)SSGameMsgID.CheckDirtyStringRes, ref res, res.Uid);
}
}
public static Dictionary<long, long> GetPlayerDicChatBlack(PlayerOnChat player)
{
Dictionary<long, long> dicChatBlack = new Dictionary<long, long>();
for (int i = 0; i < player.extData.ChatBlackList.Count; i++)
{
if (player.extData.ChatBlackList[i].Uid == 0) continue;
dicChatBlack[player.extData.ChatBlackList[i].Uid] = player.extData.ChatBlackList[i].ChatBlackTime;
TraceLog.Trace("ChatSvc.GetPlayerDicChatBlack uid {0} chatBlackUid {1} chatBlackTime {2} dicChatBlackCount {3}", player.UserID, player.extData.ChatBlackList[i].Uid, player.extData.ChatBlackList[i].ChatBlackTime, dicChatBlack.Count);
}
return dicChatBlack;
}
public static List<long> GetFilterChatBlackPlayer(PlayerOnChat player, List<long> sessionIDList)
{
List<long> sessionIDFilterList = new List<long>();
Dictionary<long, long> dicChatBlack = GetPlayerDicChatBlack(player);
foreach (var value in sessionIDList)
{
PlayerOnChat playerChat = ChatServerUtils.GetPlayerTableOp().GetPlayerOnChat(value);
if (playerChat == null)
{
TraceLog.Trace("ChatSvc.GetFilterChatBlackPlayer null uid {0} sessionID {1} dicChatBlackCount {2}", player.UserID, value, dicChatBlack.Count);
sessionIDFilterList.Add(value);
continue;
}
if (dicChatBlack == null || dicChatBlack.Count <= 0 || !dicChatBlack.ContainsKey(playerChat.UserID))
{
TraceLog.Trace("ChatSvc.GetFilterChatBlackPlayer nofilter uid {0} sessionID {1} chatBlackUid {2} dicChatBlackCount {3}", player.UserID, value, playerChat.UserID, dicChatBlack.Count);
sessionIDFilterList.Add(value);
}
else
{
TraceLog.Trace("ChatSvc.GetFilterChatBlackPlayer filter uid {0} sessionID {1} chatBlackUid {2} dicChatBlackCount {3}", player.UserID, value, playerChat.UserID, dicChatBlack.Count);
}
}
TraceLog.Trace("ChatSvc.GetFilterChatBlackPlayer uid {0} sessionIDListCount {1} sessionIDFilterListCount {2} dicChatBlackCount {3}", player.UserID, sessionIDList.Count, sessionIDFilterList.Count, dicChatBlack.Count);
return sessionIDFilterList;
}
}
}