forked from PGR/ascnet
1
0
Fork 0
This commit is contained in:
Master 2023-10-11 19:39:08 +02:00
commit eaf0a33329
6 changed files with 807 additions and 477 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="MessagePack" Version="2.5.129" /> <PackageReference Include="MessagePack" Version="2.5.129" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,6 +1,6 @@
using AscNet.Common.MsgPack; using AscNet.Common.MsgPack;
using MessagePack; using MessagePack;
using static AscNet.GameServer.Packet; using Newtonsoft.Json;
namespace AscNet.GameServer.Handlers namespace AscNet.GameServer.Handlers
{ {
@ -9,7 +9,6 @@ namespace AscNet.GameServer.Handlers
[PacketHandler("HandshakeRequest")] [PacketHandler("HandshakeRequest")]
public static void HandshakeRequestHandler(Session session, byte[] packet) public static void HandshakeRequestHandler(Session session, byte[] packet)
{ {
HandshakeRequest request = MessagePackSerializer.Deserialize<HandshakeRequest>(packet);
HandshakeResponse response = new() HandshakeResponse response = new()
{ {
Code = 0, Code = 0,
@ -23,13 +22,17 @@ namespace AscNet.GameServer.Handlers
[PacketHandler("LoginRequest")] [PacketHandler("LoginRequest")]
public static void LoginRequestHandler(Session session, byte[] packet) public static void LoginRequestHandler(Session session, byte[] packet)
{ {
LoginRequest request = MessagePackSerializer.Deserialize<LoginRequest>(packet);
session.SendResponse(new LoginResponse session.SendResponse(new LoginResponse
{ {
Code = 0, Code = 0,
ReconnectToken = "eeeeeeeeeeeeeeh", ReconnectToken = "eeeeeeeeeeeeeeh",
UtcOffset = 0, UtcOffset = 0,
UtcServerTime = (uint)DateTime.UtcNow.Ticks UtcServerTime = (uint)DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
}); });
NotifyLogin notifyLogin = JsonConvert.DeserializeObject<NotifyLogin>(File.ReadAllText("Data/NotifyLogin.json"))!;
session.SendPush(notifyLogin);
} }
} }
} }

View File

@ -67,17 +67,22 @@ namespace AscNet.GameServer
} }
foreach (var packet in packets) foreach (var packet in packets)
{
byte[] debugContent = packet.Content;
try
{ {
switch (packet.Type) switch (packet.Type)
{ {
case Packet.ContentType.Request: case Packet.ContentType.Request:
Packet.Request request = MessagePackSerializer.Deserialize<Packet.Request>(packet.Content); Packet.Request request = MessagePackSerializer.Deserialize<Packet.Request>(packet.Content);
c.Log(request.Name); c.Log(request.Name);
debugContent = request.Content;
PacketFactory.GetPacketHandler(request.Name)?.Invoke(this, request.Content); PacketFactory.GetPacketHandler(request.Name)?.Invoke(this, request.Content);
break; break;
case Packet.ContentType.Push: case Packet.ContentType.Push:
Packet.Push push = MessagePackSerializer.Deserialize<Packet.Push>(packet.Content); Packet.Push push = MessagePackSerializer.Deserialize<Packet.Push>(packet.Content);
c.Log(push.Name); c.Log(push.Name);
debugContent = push.Content;
PacketFactory.GetPacketHandler(push.Name)?.Invoke(this, push.Content); PacketFactory.GetPacketHandler(push.Name)?.Invoke(this, push.Content);
break; break;
case Packet.ContentType.Exception: case Packet.ContentType.Exception:
@ -85,9 +90,15 @@ namespace AscNet.GameServer
c.Error($"Exception packet received: {exception.Code}, {exception.Message}"); c.Error($"Exception packet received: {exception.Code}, {exception.Message}");
break; break;
default: default:
c.Error($"Unknown packet received: {packet}");
break; break;
} }
} }
catch (Exception ex)
{
c.Error("Failed to invoke handler: " + ex.Message + $", Raw {packet.Type} packet: " + BitConverter.ToString(debugContent).Replace("-", ""));
}
}
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"1.30.0": { "1.30.0": {
"DocumentVersion": "1.30.4", "DocumentVersion": "1.30.4",
"LaunchModuleVersion": "1.30.3", "LaunchModuleVersion": "1.30.4",
"IndexMd5": "c5d4baac85a6e37b8109ea43dc045d31", "IndexMd5": "c5d4baac85a6e37b8109ea43dc045d31",
"IndexSha1": "620d11a71e95e13ff2062d0e2a64466b596d8b78", "IndexSha1": "620d11a71e95e13ff2062d0e2a64466b596d8b78",
"LaunchIndexSha1": "334196cd32a865ae030f39407b198016af0a8aa9" "LaunchIndexSha1": "334196cd32a865ae030f39407b198016af0a8aa9"

View File

@ -0,0 +1,315 @@
{
"PlayerData": {
"Id": 10000001,
"Name": "Test",
"Level": 50,
"Sign": "",
"DisplayCharId": 1021001,
"Birthday": {
"Mon": 1,
"Day": 1
},
"HonorLevel": 1,
"ServerId": "5001",
"Likes": 0,
"CurrTeamId": 1,
"ChallengeEventId": 0,
"CurrHeadPortraitId": 9000002,
"CurrHeadFrameId": 0,
"CurrMedalId": 0,
"AppearanceShowType": 0,
"DailyReceiveGiftCount": 0,
"DailyActivenessRewardStatus": 0,
"WeeklyActivenessRewardStatus": 0,
"Marks": [],
"ShowCharacters": [
1021001
],
"ShieldFuncList": [],
"AppearanceSettingInfo": {
"TitleType": 1,
"CharacterType": 1,
"FashionType": 1,
"WeaponFashionType": 1,
"DormitoryType": 1,
"DormitoryId": 21001
},
"CreateTime": 1626538573,
"LastLoginTime": 1691332946,
"ReportTime": 0,
"ChangeNameTime": 1626547796,
"Flags": 0
},
"TimeLimitCtrlConfigList": [],
"SharePlatformConfigList": [
{
"Id": 0,
"SdkId": [
1,
2,
3,
4,
5
]
},
{
"Id": 35,
"SdkId": [
1,
2
]
},
{
"Id": 20,
"SdkId": [
1,
2
]
},
{
"Id": 23,
"SdkId": [
1,
2
]
},
{
"Id": 1,
"SdkId": [
1,
2
]
},
{
"Id": 2,
"SdkId": []
},
{
"Id": 11,
"SdkId": [
1,
2
]
},
{
"Id": 14,
"SdkId": [
1,
2
]
},
{
"Id": 16,
"SdkId": [
1,
2
]
},
{
"Id": 15,
"SdkId": [
1,
2
]
},
{
"Id": 24,
"SdkId": [
1,
2
]
},
{
"Id": 70,
"SdkId": [
1,
2
]
},
{
"Id": 46,
"SdkId": []
},
{
"Id": 94,
"SdkId": [
1,
2
]
},
{
"Id": 69,
"SdkId": [
1,
2
]
},
{
"Id": 13,
"SdkId": [
1,
2
]
},
{
"Id": 18,
"SdkId": [
1,
2,
3,
4
]
},
{
"Id": 136,
"SdkId": [
1,
2
]
},
{
"Id": 56,
"SdkId": [
1,
2,
3,
4
]
}
],
"ItemList": [],
"ItemRecycleDict": {},
"CharacterList": [
{
"Id": 1021001,
"Level": 50,
"Exp": 564,
"Quality": 2,
"InitQuality": 1,
"Star": 4,
"Grade": 8,
"SkillList": [
{
"Id": 102101,
"Level": 12
},
{
"Id": 102106,
"Level": 11
},
{
"Id": 102111,
"Level": 11
},
{
"Id": 102116,
"Level": 12
},
{
"Id": 102117,
"Level": 11
},
{
"Id": 102118,
"Level": 10
},
{
"Id": 102121,
"Level": 10
},
{
"Id": 102123,
"Level": 1
},
{
"Id": 102122,
"Level": 1
}
],
"EnhanceSkillList": [],
"FashionId": 6210101,
"CreateTime": 1626538573,
"TrustLv": 2,
"TrustExp": 80,
"Ability": 3387,
"LiberateLv": 2,
"CharacterHeadInfo": {
"HeadFashionId": 0,
"HeadFashionType": 0
}
}
],
"EquipList": [
{
"Id": 1,
"TemplateId": 3035002,
"CharacterId": 1021001,
"Level": 45,
"Exp": 60,
"Breakthrough": 4,
"ResonanceInfo": [],
"UnconfirmedResonanceInfo": [],
"AwakeSlotList": [],
"IsLock": false,
"CreateTime": 1626632133,
"IsRecycle": false
}
],
"FashionList": [
{
"Id": 6210101,
"IsLock": false
}
],
"HeadPortraitList": [
{
"Id": 9000001,
"LeftCount": 1,
"BeginTime": 1672341323
}
],
"BaseEquipLoginData": {
"BaseEquipList": [],
"DressedList": []
},
"FubenData": {
"StageData": {},
"FubenBaseData": {
"RefreshTime": 0,
"SelectedCharId": 1021001,
"UrgentAlarmCount": 0,
"WeeklyUrgentCount": 0,
"DayUrgentCount": {}
},
"UnlockHideStages": [],
"StageDifficulties": []
},
"FubenMainLineData": {
"TreasureData": [],
"LastPassStage": {},
"MainChapterEventInfos": []
},
"FubenChapterExtraLoginData": {
"TreasureData": [],
"LastPassStage": [],
"ChapterEventInfos": []
},
"FubenUrgentEventData": {
"UrgentEventData": {}
},
"AutoFightRecords": [],
"TeamGroupData": {},
"TeamPrefabData": {},
"SignInfos": [],
"AssignChapterRecord": [],
"WeaponFashionList": [],
"PartnerList": [],
"ShieldedProtocolList": [],
"LimitedLoginData": null,
"UseBackgroundId": 14000001,
"FubenShortStoryLoginData": {
"TreasureData": [],
"LastPassStage": [],
"ChapterEventInfos": []
}
}