forked from PGR/ascnet
1
0
Fork 0
ascnet/AscNet.GameServer/Handlers/AccountModule.cs

519 lines
19 KiB
C#
Raw Normal View History

2023-10-10 09:56:08 +00:00
using AscNet.Common.MsgPack;
using MessagePack;
2023-10-11 13:20:26 +00:00
using Newtonsoft.Json;
2023-10-10 09:56:08 +00:00
namespace AscNet.GameServer.Handlers
{
internal class AccountModule
{
[PacketHandler("HandshakeRequest")]
public static void HandshakeRequestHandler(Session session, byte[] packet)
{
// TODO: make this somehow universal, look into better architecture to handle packets
// and automatically log their deserialized form
HandshakeRequest request = MessagePackSerializer.Deserialize<HandshakeRequest>(packet);
session.c.Log("HandshakeRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-10 09:56:08 +00:00
HandshakeResponse response = new()
{
Code = 0,
UtcOpenTime = 0,
Sha1Table = null
};
session.SendResponse(response);
}
2023-10-10 13:59:08 +00:00
[PacketHandler("LoginRequest")]
public static void LoginRequestHandler(Session session, byte[] packet)
{
2023-10-11 13:20:26 +00:00
LoginRequest request = MessagePackSerializer.Deserialize<LoginRequest>(packet);
session.c.Log("LoginRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-10 13:59:08 +00:00
session.SendResponse(new LoginResponse
{
Code = 0,
ReconnectToken = "eeeeeeeeeeeeeeh",
UtcOffset = 0,
2023-10-10 18:22:41 +00:00
UtcServerTime = (uint)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
2023-10-10 13:59:08 +00:00
});
2023-10-10 18:22:41 +00:00
2023-10-11 18:32:25 +00:00
DoLogin(session);
}
[PacketHandler("EnterWorldChatRequest")]
public static void EnterWorldChatRequestHandler(Session session, byte[] packet)
{
//EnterWorldChatRequest request = MessagePackSerializer.Deserialize<EnterWorldChatRequest>(packet);
//session.c.Log("EnterWorldChatRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-11 18:32:25 +00:00
EnterWorldChatResponse enterWorldChatResponse = new()
{
Code = 0,
ChannelId = 0
};
session.SendResponse(enterWorldChatResponse);
}
[PacketHandler("GetWorldChannelInfoRequest")]
public static void GetWorldChannelInfoRequestHandler(Session session, byte[] packet)
{
//GetWorldChannelInfoRequest request = MessagePackSerializer.Deserialize<GetWorldChannelInfoRequest>(packet);
//session.c.Log("GetWorldChannelInfoRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-12 15:20:53 +00:00
GetWorldChannelInfoResponse getWorldChannelInfoResponse = new();
2023-10-11 18:32:25 +00:00
getWorldChannelInfoResponse.ChannelInfos.Append(new()
{
ChannelId = 0,
PlayerNum = 0
});
session.SendResponse(getWorldChannelInfoResponse);
}
[PacketHandler("OfflineMessageRequest")]
public static void OfflineMessageRequestHandler(Session session, byte[] packet)
{
OfflineMessageRequest request = MessagePackSerializer.Deserialize<OfflineMessageRequest>(packet);
session.c.Log("OfflineMessageRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-11 18:32:25 +00:00
OfflineMessageResponse offlineMessageResponse = new()
{
Code = 0,
2023-10-12 15:20:53 +00:00
Messages = Array.Empty<dynamic>()
2023-10-11 18:32:25 +00:00
};
session.SendResponse(offlineMessageResponse);
}
[PacketHandler("HeartbeatRequest")]
public static void HeartbeatRequestHandler(Session session, byte[] packet)
{
//HeartbeatRequest request = MessagePackSerializer.Deserialize<HeartbeatRequest>(packet);
//session.c.Log("HeartbeatRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-11 18:32:25 +00:00
HeartbeatResponse heartbeatResponse = new()
{
UtcServerTime = (uint)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
};
session.SendResponse(heartbeatResponse);
}
[PacketHandler("DoClientTaskEventRequest")]
public static void DoClientTaskEventRequestHandler(Session session, byte[] packet)
{
DoClientTaskEventRequest request = MessagePackSerializer.Deserialize<DoClientTaskEventRequest>(packet);
session.c.Log("DoClientTaskEventRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-11 18:32:25 +00:00
DoClientTaskEventResponse doClientTaskEventResponse = new()
{
Code = 0
};
session.SendResponse(doClientTaskEventResponse);
}
[PacketHandler("SignInRequest")]
public static void SignInRequestHandler(Session session, byte[] packet)
{
SignInRequest request = MessagePackSerializer.Deserialize<SignInRequest>(packet);
session.c.Log("SignInRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-11 18:32:25 +00:00
2023-10-12 15:20:53 +00:00
SignInResponse signInResponse = new();
2023-10-11 18:32:25 +00:00
session.SendResponse(signInResponse);
}
[PacketHandler("GetPurchaseListRequest")]
public static void GetPurchaseListRequestHandler(Session session, byte[] packet)
{
GetPurchaseListRequest request = MessagePackSerializer.Deserialize<GetPurchaseListRequest>(packet);
session.c.Log("GetPurchaseListRequest" + " " + JsonConvert.SerializeObject(request));
2023-10-11 18:32:25 +00:00
2023-10-12 15:20:53 +00:00
GetPurchaseListResponse getPurchaseListResponse = new();
2023-10-11 18:32:25 +00:00
session.SendResponse(getPurchaseListResponse);
}
// TODO: Move somewhere else, also split.
2023-10-11 18:32:25 +00:00
static void DoLogin(Session session)
{
2023-10-11 13:20:26 +00:00
NotifyLogin notifyLogin = JsonConvert.DeserializeObject<NotifyLogin>(File.ReadAllText("Data/NotifyLogin.json"))!;
session.SendPush(notifyLogin);
2023-10-11 18:32:25 +00:00
2023-10-12 15:20:53 +00:00
NotifyDailyLotteryData notifyDailyLotteryData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyDailyLotteryData);
NotifyPayInfo notifyPayInfo = new()
{
TotalPayMoney = 0,
IsGetFirstPayReward = false
};
session.SendPush(notifyPayInfo);
2023-10-12 15:20:53 +00:00
NotifyEquipChipGroupList notifyEquipChipGroupList = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyEquipChipGroupList);
NotifyEquipChipAutoRecycleSite notifyEquipChipAutoRecycleSite = new()
{
2023-10-12 15:20:53 +00:00
ChipRecycleSite = new NotifyEquipChipAutoRecycleSite.NotifyEquipChipAutoRecycleSiteChipRecycleSite()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyEquipChipAutoRecycleSite);
NotifyEquipGuideData notifyEquipGuideData = new()
{
EquipGuideData = new()
};
session.SendPush(notifyEquipGuideData);
2023-10-12 15:20:53 +00:00
NotifyArchiveLoginData notifyArchiveLoginData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyArchiveLoginData);
NotifyChatLoginData notifyChatLoginData = new()
{
2023-10-12 15:20:53 +00:00
RefreshTime = GetPlaceholderTime()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyChatLoginData);
2023-10-12 15:20:53 +00:00
NotifySocialData notifySocialData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifySocialData);
2023-10-11 20:44:58 +00:00
NotifyTaskData notifyTaskData = JsonConvert.DeserializeObject<NotifyTaskData>(File.ReadAllText("Data/NotifyTaskData.json"))!;
//NotifyTaskData notifyTaskData = new()
//{
2023-10-12 15:20:53 +00:00
// TaskData = Array.Empty<dynamic>()
2023-10-11 20:44:58 +00:00
//};
2023-10-11 18:32:25 +00:00
session.SendPush(notifyTaskData);
2023-10-12 15:20:53 +00:00
NotifyActivenessStatus notifyActivenessStatus = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyActivenessStatus);
NotifyNewPlayerTaskStatus notifyNewPlayerTaskStatus = new()
{
NewPlayerTaskActiveDay = 1
};
session.SendPush(notifyNewPlayerTaskStatus);
NotifyRegression2Data notifyRegression2Data = new()
{
2023-10-12 15:20:53 +00:00
Data = new NotifyRegression2Data.NotifyRegression2DataData()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyRegression2Data);
2023-10-12 15:20:53 +00:00
NotifyAllRedEnvelope notifyAllRedEnvelope = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyAllRedEnvelope);
2023-10-12 15:20:53 +00:00
NotifyScoreTitleData notifyScoreTitleData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyScoreTitleData);
NotifyBfrtData notifyBfrtData = new()
{
BfrtData = new()
};
session.SendPush(notifyBfrtData);
NotifyGuildEvent notifyGuildEvent = new();
session.SendPush(notifyGuildEvent);
NotifyAssistData NotifyAssistData = new()
{
AssistData = new()
{
AssistCharacterId = 1021001
}
};
session.SendPush(NotifyAssistData);
NotifyWorkNextRefreshTime notifyWorkNextRefreshTime = new()
{
NextRefreshTime = GetPlaceholderTime()
};
session.SendPush(notifyWorkNextRefreshTime);
2023-10-12 15:20:53 +00:00
NotifyDormitoryData notifyDormitoryData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyDormitoryData);
2023-10-12 15:20:53 +00:00
NotifyNameplateLoginData notifyNameplateLoginData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyNameplateLoginData);
NotifyGuildDormPlayerData notifyGuildDormPlayerData = new()
{
2023-10-12 15:20:53 +00:00
GuildDormData = new NotifyGuildDormPlayerData.NotifyGuildDormPlayerDataGuildDormData()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyGuildDormPlayerData);
NotifyBountyTaskInfo notifyBountyTaskInfo = new()
{
2023-10-12 15:20:53 +00:00
TaskInfo = new NotifyBountyTaskInfo.NotifyBountyTaskInfoTaskInfo
{
RankLevel = 1,
TaskPoolRefreshCount = 0
},
2023-10-11 18:32:25 +00:00
RefreshTime = GetPlaceholderTime()
};
session.SendPush(notifyBountyTaskInfo);
2023-10-12 15:20:53 +00:00
NotifyFiveTwentyRecord notifyFiveTwentyRecord = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyFiveTwentyRecord);
2023-10-12 15:20:53 +00:00
PurchaseDailyNotify purchaseDailyNotify = new();
2023-10-11 18:58:04 +00:00
session.SendPush(purchaseDailyNotify);
NotifyPurchaseRecommendConfig notifyPurchaseRecommendConfig = new()
{
2023-10-12 15:20:53 +00:00
Data = new NotifyPurchaseRecommendConfig.NotifyPurchaseRecommendConfigData
{
AddOrModifyConfigs = new(),
RemoveIds = Array.Empty<dynamic>()
}
2023-10-11 18:58:04 +00:00
};
session.SendPush(notifyPurchaseRecommendConfig);
2023-10-12 15:20:53 +00:00
NotifyBackgroundLoginData notifyBackgroundLoginData = new();
2023-10-11 18:58:04 +00:00
session.SendPush(notifyBackgroundLoginData);
2023-10-12 15:20:53 +00:00
NotifyMedalData notifyMedalData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyMedalData);
2023-10-12 15:20:53 +00:00
NotifyExploreData notifyExploreData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyExploreData);
2023-10-12 15:20:53 +00:00
NotifyGatherRewardList notifyGatherRewardList = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyGatherRewardList);
2023-10-12 15:20:53 +00:00
NotifyDrawTicketData notifyDrawTicketData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyDrawTicketData);
NotifyAccumulatedPayData notifyAccumulatedPayData = new()
{
PayId = 1,
2023-10-12 15:20:53 +00:00
PayMoney = 0
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyAccumulatedPayData);
NotifyArenaActivity notifyArenaActivity = new();
session.SendPush(notifyArenaActivity);
2023-10-12 15:20:53 +00:00
NotifyPrequelUnlockChallengeStages notifyPrequelUnlockChallengeStages = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyPrequelUnlockChallengeStages);
NotifyPrequelChallengeRefreshTime notifyPrequelChallengeRefreshTime = new()
{
NextRefreshTime = GetPlaceholderTime()
};
session.SendPush(notifyPrequelChallengeRefreshTime);
NotifyFubenPrequelData notifyFubenPrequelData = new()
{
2023-10-12 15:20:53 +00:00
FubenPrequelData = new()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyFubenPrequelData);
NotifyMainLineActivity notifyMainLineActivity = new()
{
BfrtChapter = 0,
EndTime = GetPlaceholderTime(),
HideChapterBeginTime = 0
};
session.SendPush(notifyMainLineActivity);
NotifyDailyFubenLoginData notifyDailyFubenLoginData = new()
{
2023-10-12 15:20:53 +00:00
RefreshTime = GetPlaceholderTime()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyDailyFubenLoginData);
NotifyBirthdayPlot notifyBirthdayPlot = new()
{
NextActiveYear = 2023,
2023-10-12 15:20:53 +00:00
IsChange = 1
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyBirthdayPlot);
2023-10-12 15:20:53 +00:00
NotifyBossActivityData notifyBossActivityData = new()
2023-10-11 18:32:25 +00:00
{
2023-10-12 15:20:53 +00:00
ActivityId = 11,
SectionId = 1,
Schedule = 0
2023-10-11 18:32:25 +00:00
};
2023-10-12 15:20:53 +00:00
session.SendPush(notifyBossActivityData);
NotifyBriefStoryData notifyBriefStoryData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyBriefStoryData);
2023-10-12 15:20:53 +00:00
NotifyChessPursuitGroupInfo notifyChessPursuitGroupInfo = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyChessPursuitGroupInfo);
2023-10-12 15:20:53 +00:00
NotifyClickClearData notifyClickClearData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyClickClearData);
NotifyCourseData notifyCourseData = new()
{
2023-10-12 15:20:53 +00:00
Data = new NotifyCourseData.NotifyCourseDataData
{
MaxTotalLessonPoint = 0,
StageDataDict = new Dictionary<dynamic, dynamic>(),
TotalLessonPoint = 0
}
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyCourseData);
2023-10-12 15:20:53 +00:00
NotifyActivityDrawList notifyActivityDrawList = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyActivityDrawList);
NotifyActivityDrawGroupCount notifyActivityDrawGroupCount = new()
{
Count = 1
};
session.SendPush(notifyActivityDrawGroupCount);
2023-10-12 15:20:53 +00:00
NotifyExperimentData notifyExperimentData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyExperimentData);
2023-10-12 17:04:10 +00:00
NotifyBabelTowerData notifyBabelTowerData = new()
{
ActivityNo = 13,
MaxScore = 0,
RankLevel = 0,
StageDatas = new(),
ExtraData = new()
};
session.SendPush(notifyBabelTowerData);
/* Not needed?
2023-10-11 18:32:25 +00:00
NotifyBabelTowerActivityStatus notifyBabelTowerActivityStatus = new();
session.SendPush(notifyBabelTowerActivityStatus);
2023-10-12 17:04:10 +00:00
*/
2023-10-11 18:32:25 +00:00
NotifyFubenBossSingleData notifyFubenBossSingleData = new()
{
2023-10-12 15:20:53 +00:00
FubenBossSingleData = new NotifyFubenBossSingleData.NotifyFubenBossSingleDataFubenBossSingleData()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyFubenBossSingleData);
2023-10-12 15:20:53 +00:00
NotifyFestivalData notifyFestivalData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyFestivalData);
2023-10-12 15:20:53 +00:00
NotifyPracticeData notifyPracticeData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyPracticeData);
2023-10-12 15:20:53 +00:00
NotifyTrialData notifyTrialData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyTrialData);
NotifyPivotCombatData notifyPivotCombatData = new()
{
2023-10-12 15:20:53 +00:00
PivotCombatData = new NotifyPivotCombatData.NotifyPivotCombatDataPivotCombatData
{
ActivityId = 0,
Difficulty = 0
}
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyPivotCombatData);
NotifySettingLoadingOption notifySettingLoadingOption = new()
{
LoadingData = null
};
session.SendPush(notifySettingLoadingOption);
2023-10-12 15:20:53 +00:00
NotifyTask notifyTask = new()
{
TaskLimitIdActiveInfos = Array.Empty<int>()
};
NotifyRepeatChallengeData notifyRepeatChallengeData = new()
{
Id = 20,
ExpInfo = new() { Level = 1 }
};
2023-10-11 18:32:25 +00:00
session.SendPush(notifyRepeatChallengeData);
2023-10-12 17:04:10 +00:00
2023-10-12 15:20:53 +00:00
2023-10-11 18:32:25 +00:00
NotifyPlayerReportData notifyPlayerReportData = new()
{
2023-10-12 15:20:53 +00:00
ReportData = new NotifyPlayerReportData.NotifyPlayerReportDataReportData()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyPlayerReportData);
2023-10-12 15:20:53 +00:00
NotifyReviewConfig notifyReviewConfig = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyReviewConfig);
2023-10-12 15:20:53 +00:00
NotifyStrongholdLoginData notifyStrongholdLoginData = new()
{
Id = 21
};
2023-10-11 18:32:25 +00:00
session.SendPush(notifyStrongholdLoginData);
2023-10-12 15:20:53 +00:00
NotifySummerSignInData notifySummerSignInData = new()
{
ActId = 1,
SurplusTimes = 1
};
2023-10-11 18:32:25 +00:00
session.SendPush(notifySummerSignInData);
NotifyTaikoMasterData notifyTaikoMasterData = new()
{
2023-10-12 15:20:53 +00:00
TaikoMasterData = new NotifyTaikoMasterData.NotifyTaikoMasterDataTaikoMasterData()
{
Setting = new()
}
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyTaikoMasterData);
2023-10-12 15:20:53 +00:00
NotifyTeachingActivityInfo notifyTeachingActivityInfo = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyTeachingActivityInfo);
NotifyTheatreData notifyTheatreData = new();
session.SendPush(notifyTheatreData);
2023-10-12 15:20:53 +00:00
NotifyVoteData notifyVoteData = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyVoteData);
2023-10-12 15:20:53 +00:00
NotifyTRPGData notifyTRPGData = new()
{
BossInfo = new(),
BaseInfo = new()
{
Level = 1
}
};
2023-10-11 18:32:25 +00:00
session.SendPush(notifyTRPGData);
2023-10-12 15:20:53 +00:00
NotifyBiancaTheatreActivityData notifyBiancaTheatreActivityData = new()
{
CurActivityId = 1
};
2023-10-11 18:32:25 +00:00
session.SendPush(notifyBiancaTheatreActivityData);
2023-10-12 15:20:53 +00:00
NotifyMentorData notifyMentorData = new()
2023-10-11 18:32:25 +00:00
{
2023-10-12 15:20:53 +00:00
PlayerType = 2,
Announcement = "",
WeeklyLevel = 28
2023-10-11 18:32:25 +00:00
};
2023-10-12 15:20:53 +00:00
session.SendPush(notifyMentorData);
NotifyMentorChat notifyMentorChat = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyMentorChat);
2023-10-12 15:20:53 +00:00
NotifyMaintainerActionDailyReset notifyMaintainerActionDailyReset = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyMaintainerActionDailyReset);
2023-10-12 15:20:53 +00:00
NotifyGuildData notifyGuildData = new()
2023-10-11 18:32:25 +00:00
{
2023-10-12 15:20:53 +00:00
GuildName = string.Empty,
GuildRankLevel = 0
2023-10-11 18:32:25 +00:00
};
2023-10-12 15:20:53 +00:00
session.SendPush(notifyGuildData);
NotifyMails notifyMails = new();
2023-10-11 18:32:25 +00:00
session.SendPush(notifyMails);
NotifyItemDataList notifyItemDataList = new()
{
2023-10-12 15:20:53 +00:00
ItemRecycleDict = Array.Empty<dynamic>()
2023-10-11 18:32:25 +00:00
};
session.SendPush(notifyItemDataList);
2023-10-10 13:59:08 +00:00
}
2023-10-11 18:32:25 +00:00
static uint GetPlaceholderTime() => (uint)(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() + DateTimeOffset.UtcNow.AddHours(1).ToUnixTimeMilliseconds());
2023-10-10 09:56:08 +00:00
}
}