2023-08-22 19:08:45 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//
|
|
|
|
|
|
// 文件:Assets/Code/Scripts/Gameplay/Net/Client/NetManager.cs
|
|
|
|
|
|
// 作者:Xoen Xie
|
|
|
|
|
|
// 时间:2023/07/18
|
|
|
|
|
|
// 描述:网络管理
|
|
|
|
|
|
// 说明:
|
|
|
|
|
|
//
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using Framework;
|
2023-10-19 15:00:19 +08:00
|
|
|
|
using PhxhSDK;
|
2023-08-22 19:08:45 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Gameplay.Net
|
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
public sealed class NetManager : Singlenton<NetManager>, IUpdatable, IInitable
|
2023-08-22 19:08:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
public NetClient mClient { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
private uint m_nClientID;
|
|
|
|
|
|
|
|
|
|
|
|
private IMessage []m_MessagePool;
|
|
|
|
|
|
|
2024-09-14 19:17:45 +08:00
|
|
|
|
public RC4Cipher Rc4Cipher { get; private set; }
|
|
|
|
|
|
|
2023-08-22 19:08:45 +08:00
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("NetManager Init start");
|
|
|
|
|
|
InitPools();
|
|
|
|
|
|
|
|
|
|
|
|
m_nClientID = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Release()
|
|
|
|
|
|
{
|
2023-11-14 15:54:36 +08:00
|
|
|
|
DebugUtil.Log("NetManager Release start");
|
2023-08-22 19:08:45 +08:00
|
|
|
|
CloseClient();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CloseClient()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mClient != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
mClient.Release();
|
|
|
|
|
|
mClient = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NetClient CreateNetClient(string sIP, int nPort)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mClient != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.Log("CreateNetClient mClient.Release");
|
|
|
|
|
|
mClient.Release();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mClient = new NetClient();
|
|
|
|
|
|
mClient.mID = m_nClientID++;
|
|
|
|
|
|
if (!mClient.Create(sIP, nPort))
|
|
|
|
|
|
{
|
|
|
|
|
|
mClient.Release();
|
|
|
|
|
|
mClient = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mClient.Connect();
|
2024-09-03 17:07:34 +08:00
|
|
|
|
DebugUtil.Log("IP: " + sIP + " Port: " + nPort);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
return mClient;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SendMessage(IMessage message)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mClient == null)
|
|
|
|
|
|
{
|
2023-10-19 15:00:19 +08:00
|
|
|
|
DebugUtil.LogWarning("NetManager.SendMessage mClient == null, message={0}", message.ID);
|
2023-08-22 19:08:45 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mClient.SendMessage(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Update(float deltaTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mClient != null)
|
|
|
|
|
|
mClient.Update();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void InitPools()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_MessagePool = new IMessage[(int)NLDMID.MSGID.Max];
|
|
|
|
|
|
// MESSAGE_START
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGtHandshake] = new MSG_Clt_Gt_Handshake();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GtCltHandshake] = new MSG_Gt_Clt_Handshake();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGtHeartbeat] = new MSG_Clt_Gt_Heartbeat();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GtCltHeartbeat] = new MSG_Gt_Clt_Heartbeat();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GtCltDisconnect] = new MSG_Gt_Clt_Disconnect();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLLogin] = new MSG_Clt_L_Login();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LCltLoginResult] = new MSG_L_Clt_LoginResult();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltLoginResult] = new MSG_G_Clt_LoginResult();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltOpResult] = new MSG_G_Clt_OpResult();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorBase] = new MSG_G_Clt_ActorBase();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorItem] = new MSG_G_Clt_ActorItem();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorCharacter] = new MSG_G_Clt_ActorCharacter();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGCharacterUpgrade] = new MSG_Clt_G_CharacterUpgrade();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorLogic] = new MSG_G_Clt_ActorLogic();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorTask] = new MSG_G_Clt_ActorTask();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSetNickname] = new MSG_Clt_G_SetNickname();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorLevel] = new MSG_G_Clt_ActorLevel();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGEnterLevel] = new MSG_Clt_G_EnterLevel();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGExitLevel] = new MSG_Clt_G_ExitLevel();
|
2023-10-19 15:00:19 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorRaffle] = new MSG_G_Clt_ActorRaffle();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGRaffle] = new MSG_Clt_G_Raffle();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltItemList] = new MSG_G_Clt_ItemList();
|
2024-01-08 19:14:33 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGGroupReward] = new MSG_Clt_G_GroupReward();
|
2023-10-19 15:00:19 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGVehicleUpgrade] = new MSG_Clt_G_VehicleUpgrade();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorTeam] = new MSG_G_Clt_ActorTeam();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGCreateTeam] = new MSG_Clt_G_CreateTeam();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGUseItem] = new MSG_Clt_G_UseItem();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGTestInit] = new MSG_Clt_G_TestInit();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGGiftCode] = new MSG_Clt_G_GiftCode();
|
2023-10-23 13:39:21 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.MlCltMailInfo] = new MSG_Ml_Clt_MailInfo();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltMlMailRequest] = new MSG_Clt_Ml_MailRequest();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.MlCltMailData] = new MSG_Ml_Clt_MailData();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltMlOpenMail] = new MSG_Clt_Ml_OpenMail();
|
2023-11-14 15:54:36 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.MlCltNewGlobalMail] = new MSG_Ml_Clt_NewGlobalMail();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltLoginKey] = new MSG_G_Clt_LoginKey();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGRelogin] = new MSG_Clt_G_Relogin();
|
2023-12-06 15:00:26 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltMlClaimMailItems] = new MSG_Clt_Ml_ClaimMailItems();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltMlDeleteMail] = new MSG_Clt_Ml_DeleteMail();
|
2023-12-11 14:36:01 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGTaskClaim] = new MSG_Clt_G_TaskClaim();
|
2023-12-12 19:35:47 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGGetShopContent] = new MSG_Clt_G_GetShopContent();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltShopDatas] = new MSG_G_Clt_ShopDatas();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGShopPurchase] = new MSG_Clt_G_ShopPurchase();
|
2023-12-19 12:31:51 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorPlayerSkill] = new MSG_G_Clt_ActorPlayerSkill();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGPlayerSkillUpgrade] = new MSG_Clt_G_PlayerSkillUpgrade();
|
2023-12-27 16:28:40 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSetDefenceTeamForPvp] = new MSG_Clt_G_SetDefenceTeamForPvp();
|
2024-01-02 15:15:58 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltMgPvpInformation] = new MSG_Clt_Mg_PvpInformation();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltPvpInformation] = new MSG_G_Clt_PvpInformation();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGPvpStart] = new MSG_Clt_G_PvpStart();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGPvpResult] = new MSG_Clt_G_PvpResult();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorPvp] = new MSG_G_Clt_ActorPvp();
|
2024-01-02 16:19:15 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltPvpDefenceData] = new MSG_G_Clt_PvpDefenceData();
|
2024-01-08 19:14:33 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltMgPvpOrderList] = new MSG_Clt_Mg_PvpOrderList();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.MgCltPvpOrderListData] = new MSG_Mg_Clt_PvpOrderListData();
|
2024-01-10 15:53:32 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGPatioExchange] = new MSG_Clt_G_PatioExchange();
|
2024-01-31 19:16:16 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGInAppPurchase] = new MSG_Clt_G_InAppPurchase();
|
2024-02-22 12:37:04 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorPurchase] = new MSG_G_Clt_ActorPurchase();
|
2024-05-13 15:55:47 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGExchangeItem] = new MSG_Clt_G_ExchangeItem();
|
2024-06-05 14:04:26 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGNewGuideProgress] = new MSG_Clt_G_NewGuideProgress();
|
2024-06-19 14:21:14 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSetHeadicon] = new MSG_Clt_G_SetHeadicon();
|
2024-07-09 14:02:15 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGBuyAlbum] = new MSG_Clt_G_BuyAlbum();
|
2024-07-24 19:24:11 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGAdultAuth] = new MSG_Clt_G_AdultAuth();
|
2024-09-10 12:53:57 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGLevelSweep] = new MSG_Clt_G_LevelSweep();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltHorseLight] = new MSG_G_Clt_HorseLight();
|
2024-10-11 18:17:51 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSetActorBase] = new MSG_Clt_G_SetActorBase();
|
2024-10-16 19:40:37 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGStringCheck] = new MSG_Clt_G_StringCheck();
|
2024-10-31 13:12:36 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGInAppPurchaseTest] = new MSG_Clt_G_InAppPurchaseTest();
|
2024-11-26 17:27:13 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGVehicleDevelopment] = new MSG_Clt_G_VehicleDevelopment();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGVehicleBuyPaint] = new MSG_Clt_G_VehicleBuyPaint();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGVehicleSetPaint] = new MSG_Clt_G_VehicleSetPaint();
|
2024-12-06 13:41:38 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LCltNldToken] = new MSG_L_Clt_NldToken();
|
2024-12-16 15:50:22 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionList] = new MSG_Clt_Lg_LegionList();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionListData] = new MSG_Lg_Clt_LegionListData();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgCreateLegion] = new MSG_Clt_Lg_CreateLegion();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgUpdateLegion] = new MSG_Clt_Lg_UpdateLegion();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgJoinLegion] = new MSG_Clt_Lg_JoinLegion();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgExamineJoinLegion] = new MSG_Clt_Lg_ExamineJoinLegion();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgQuitLegion] = new MSG_Clt_Lg_QuitLegion();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgUpdateMember] = new MSG_Clt_Lg_UpdateMember();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgDismissMember] = new MSG_Clt_Lg_DismissMember();
|
2024-12-23 12:12:52 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgGetMyLegionInfo] = new MSG_Clt_Lg_GetMyLegionInfo();
|
2024-12-19 14:46:02 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionBase] = new MSG_Lg_Clt_LegionBase();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionMember] = new MSG_Lg_Clt_LegionMember();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionLog] = new MSG_Lg_Clt_LegionLog();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionApply] = new MSG_Lg_Clt_LegionApply();
|
2024-12-23 12:12:52 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionPart] = new MSG_Clt_Lg_LegionPart();
|
2024-12-24 13:59:36 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGCheckCharacter] = new MSG_Clt_G_CheckCharacter();
|
2024-12-26 17:03:06 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltActorLegion] = new MSG_G_Clt_ActorLegion();
|
2025-01-08 17:12:18 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionBattleSignUp] = new MSG_Clt_Lg_LegionBattleSignUp();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGBattlePassReward] = new MSG_Clt_G_BattlePassReward();
|
2025-01-10 19:38:13 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBEnterLegionBattlefield] = new MSG_Clt_B_EnterLegionBattlefield();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGBuyBattlePassLevel] = new MSG_Clt_G_BuyBattlePassLevel();
|
2025-01-14 13:03:21 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldInfo] = new MSG_B_Clt_LegionBattlefieldInfo();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefield] = new MSG_B_Clt_LegionBattlefield();
|
2025-01-10 19:38:13 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltJoinedLegion] = new MSG_Lg_Clt_JoinedLegion();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLoseLegion] = new MSG_Lg_Clt_LoseLegion();
|
2025-01-14 13:03:21 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBEnterLegionBattlefieldOk] = new MSG_Clt_B_EnterLegionBattlefieldOk();
|
2025-01-16 17:22:20 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBLegionBattleCommand] = new MSG_Clt_B_LegionBattleCommand();
|
2025-01-23 13:06:22 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldBuilding] = new MSG_B_Clt_LegionBattlefieldBuilding();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldActor] = new MSG_B_Clt_LegionBattlefieldActor();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldActorUpdate] = new MSG_B_Clt_LegionBattlefieldActorUpdate();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldActorCommand] = new MSG_B_Clt_LegionBattlefieldActorCommand();
|
2025-03-14 12:23:10 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldCombatStart] = new MSG_B_Clt_LegionBattlefieldCombatStart();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldCombatEnd] = new MSG_B_Clt_LegionBattlefieldCombatEnd();
|
2025-01-23 13:06:22 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBLegionBattleCaptainOrder] = new MSG_Clt_B_LegionBattleCaptainOrder();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattleCaptainOrder] = new MSG_B_Clt_LegionBattleCaptainOrder();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldBuildingUpdate] = new MSG_B_Clt_LegionBattlefieldBuildingUpdate();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBLegionBattleLog] = new MSG_Clt_B_LegionBattleLog();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattleLog] = new MSG_B_Clt_LegionBattleLog();
|
2025-02-11 19:36:18 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionPostHiring] = new MSG_Clt_Lg_LegionPostHiring();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgMercenarySignUp] = new MSG_Clt_Lg_MercenarySignUp();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenaryApply] = new MSG_Clt_Lg_LegionMercenaryApply();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenaryApprove] = new MSG_Clt_Lg_LegionMercenaryApprove();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenaryHire] = new MSG_Clt_Lg_LegionMercenaryHire();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenaryHireDatas] = new MSG_Clt_Lg_LegionMercenaryHireDatas();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionMercenaryHireDatas] = new MSG_Lg_Clt_LegionMercenaryHireDatas();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenarySignUpDatas] = new MSG_Clt_Lg_LegionMercenarySignUpDatas();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionMercenarySignUpDatas] = new MSG_Lg_Clt_LegionMercenarySignUpDatas();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattleStatus] = new MSG_B_Clt_LegionBattleStatus();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBExitLegionBattlefield] = new MSG_Clt_B_ExitLegionBattlefield();
|
2025-02-18 17:14:02 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBGetLegionBattleTeams] = new MSG_Clt_B_GetLegionBattleTeams();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltGetLegionBattleTeams] = new MSG_B_Clt_GetLegionBattleTeams();
|
2025-02-25 12:39:22 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenarySearch] = new MSG_Clt_Lg_LegionMercenarySearch();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionMercenarySearch] = new MSG_Lg_Clt_LegionMercenarySearch();
|
2025-02-26 15:15:40 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionMercenaryActor] = new MSG_Lg_Clt_LegionMercenaryActor();
|
2025-02-26 19:07:05 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGRefreshShop] = new MSG_Clt_G_RefreshShop();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattleEnd] = new MSG_B_Clt_LegionBattleEnd();
|
2025-02-27 15:12:38 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGClaimMonthlyPassReward] = new MSG_Clt_G_ClaimMonthlyPassReward();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltLgLegionMercenaryDatas] = new MSG_Clt_Lg_LegionMercenaryDatas();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.LgCltLegionMercenaryDatas] = new MSG_Lg_Clt_LegionMercenaryDatas();
|
2025-03-17 15:51:39 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldHexes] = new MSG_B_Clt_LegionBattlefieldHexes();
|
2025-03-18 18:52:45 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionCombatRecords] = new MSG_B_Clt_LegionCombatRecords();
|
2025-03-19 15:59:23 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSign] = new MSG_Clt_G_Sign();
|
2025-03-21 14:43:35 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBSetLegionBattleTeamLock] = new MSG_Clt_B_SetLegionBattleTeamLock();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltBSelectLegionBattleTeam] = new MSG_Clt_B_SelectLegionBattleTeam();
|
2025-03-24 14:42:01 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.BCltLegionBattlefieldBuildingScore] = new MSG_B_Clt_LegionBattlefieldBuildingScore();
|
2025-03-27 16:05:17 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSetAvatar] = new MSG_Clt_G_SetAvatar();
|
2025-04-01 11:59:54 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGPhxhGiftCode] = new MSG_Clt_G_PhxhGiftCode();
|
2025-04-09 16:24:39 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGActivityRequest] = new MSG_Clt_G_ActivityRequest();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGGetShopList] = new MSG_Clt_G_GetShopList();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.GCltGetShopList] = new MSG_G_Clt_GetShopList();
|
|
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGUseItems] = new MSG_Clt_G_UseItems();
|
2025-04-10 13:36:39 +08:00
|
|
|
|
m_MessagePool[(int)NLDMID.MSGID.CltGSetLockStatus] = new MSG_Clt_G_SetLockStatus();
|
2023-08-22 19:08:45 +08:00
|
|
|
|
// MESSAGE_END
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IMessage GetMessage(NLDMID.MSGID id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_MessagePool[(int)id];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 服务器当前时间戳:毫秒
|
2023-12-05 18:23:03 +08:00
|
|
|
|
public ulong ServerTimeMS { get { return m_ServerTimeStart + (PhxhSDK.Utils.GetTimeStampMilliseconds() - m_ClientTimeStart); } }
|
2023-08-22 19:08:45 +08:00
|
|
|
|
|
|
|
|
|
|
// 服务器当前时间戳:秒
|
|
|
|
|
|
public uint ServerTime { get { return (uint)(ServerTimeMS / 1000); } }
|
|
|
|
|
|
|
|
|
|
|
|
// 服务器发送心跳的时间
|
|
|
|
|
|
private ulong m_ServerTimeStart;
|
|
|
|
|
|
|
|
|
|
|
|
// 服务器发送心跳时,客户端的时间
|
|
|
|
|
|
private ulong m_ClientTimeStart;
|
|
|
|
|
|
|
|
|
|
|
|
// 消息从客户端 ——> 服务器 -->客户端的总时间的一半
|
|
|
|
|
|
public uint RTT { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
public void SetTime(ulong clientTime, ulong serverTime)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_ServerTimeStart = serverTime; // 服务器回复心跳的时间
|
|
|
|
|
|
|
2023-12-05 18:23:03 +08:00
|
|
|
|
ulong current = PhxhSDK.Utils.GetTimeStampMilliseconds();
|
2023-08-22 19:08:45 +08:00
|
|
|
|
ulong timePass = current - clientTime;
|
|
|
|
|
|
RTT = (uint)(timePass / 2);
|
|
|
|
|
|
|
|
|
|
|
|
m_ClientTimeStart = current - RTT;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|