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.
77 lines
2.1 KiB
77 lines
2.1 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
|
|
using ProtoCSStruct;
|
|
using Chat;
|
|
|
|
namespace Chat
|
|
{
|
|
|
|
|
|
public class RealmlistSvc
|
|
{
|
|
private static long m_lastTickTime = 0;
|
|
private static long lastForceGetAllRealmTime = 0;
|
|
|
|
public static void OnRealmBriefRes(uint serverID, StructPacket packet)
|
|
{
|
|
ref var res = ref packet.GetMessage<SSRealmBriefRes>();
|
|
|
|
var svrData = ChatServerUtils.GetChatServerData();
|
|
|
|
for (int i = 0; i < res.RealmList.Count; i++)
|
|
{
|
|
var realm = new RealmBriefInfo(ref res.RealmList[i]);
|
|
svrData.m_allRealmMap[realm.realmId] = realm;
|
|
}
|
|
|
|
if (!res.RealmListMd5.IsEmpty())
|
|
{
|
|
svrData.recvRealmListMd5 = res.RealmListMd5.GetString();
|
|
}
|
|
|
|
TraceLog.Trace("OnRealmBriefRes count {0} svrData.recvRealmListMd5 {1}", svrData.m_allRealmMap.Count, svrData.recvRealmListMd5);
|
|
|
|
}
|
|
|
|
public static void OnTick(long nowMs)
|
|
{
|
|
long nowSec = nowMs / 1000;
|
|
|
|
int timeReqInterval = 60;
|
|
//缺省一分钟一次,如果没成功拉到过列表,则10秒一次
|
|
if (string.IsNullOrEmpty(ChatServerUtils.GetChatServerData().recvRealmListMd5))
|
|
{
|
|
timeReqInterval = 10;
|
|
}
|
|
//60秒一次
|
|
if (nowSec - m_lastTickTime < timeReqInterval)
|
|
{
|
|
return;
|
|
}
|
|
|
|
m_lastTickTime = nowSec;
|
|
|
|
var realmReq = new SSRealmBriefReq { GameSvrId = ChatServerUtils.GetAppID() };
|
|
//为了以防万一,每10分钟强制拉一次全量
|
|
if (nowSec - lastForceGetAllRealmTime >= 600)
|
|
{
|
|
lastForceGetAllRealmTime = nowSec;
|
|
}
|
|
else
|
|
{
|
|
realmReq.RealmListMd5.SetString(ChatServerUtils.GetChatServerData().recvRealmListMd5);
|
|
}
|
|
|
|
ChatServerUtils.GetPacketSender().SendToWorldServer((int)SSMsgID.RealmBriefReq, ref realmReq, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|