Skip to content

Commit

Permalink
[Core] Corrected Protobuf Field Name
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan04 committed Oct 17, 2024
1 parent 93c35bc commit f9db6de
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
22 changes: 12 additions & 10 deletions Lagrange.Core/Internal/Packets/Message/ContentHead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,29 @@ namespace Lagrange.Core.Internal.Packets.Message;
[ProtoContract]
internal class ContentHead
{
[ProtoMember(1)] public uint Type { get; set; }
[ProtoMember(1)] public uint Type { get; set; } // 消息类型

[ProtoMember(2)] public uint? SubType { get; set; }
[ProtoMember(2)] public uint? SubType { get; set; } // 消息子类型(0x211\0x2dc\0x210等系统消息的子类型,取值同c2c_cmd)

[ProtoMember(3)] public uint? DivSeq { get; set; }
[ProtoMember(3)] public uint? C2CCmd { get; set; } // c2c消息子类型

[ProtoMember(4)] public long? MsgId { get; set; }
[ProtoMember(4)] public long? Random { get; set; }

[ProtoMember(5)] public uint? Sequence { get; set; }

[ProtoMember(6)] public long? Timestamp { get; set; }

[ProtoMember(7)] public long? Field7 { get; set; }
[ProtoMember(7)] public long? PkgNum { get; set; } // 分包数目,消息需要分包发送时该值不为1

[ProtoMember(8)] public uint? Field8 { get; set; }
[ProtoMember(8)] public uint? PkgIndex { get; set; } // 当前分包索引,从 0开始

[ProtoMember(9)] public uint? DivSeq { get; set; } // 消息分包的序列号,同一条消息的各个分包的 div_seq 相同

[ProtoMember(10)] public uint AutoReply { get; set; }

[ProtoMember(9)] public uint? Field9 { get; set; }
[ProtoMember(11)] public uint? NTMsgSeq { get; set; } // 两个uin之间c2c消息唯一递增seq

[ProtoMember(11)] public uint? FriendSequence { get; set; }

[ProtoMember(12)] public ulong? NewId { get; set; }
[ProtoMember(12)] public ulong? MsgUid { get; set; }

[ProtoMember(15)] public ForwardHead? Forward { get; set; }
}
18 changes: 9 additions & 9 deletions Lagrange.Core/Message/MessagePacker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static MessageChain ParsePrivateFile(PushMsgBody message)
{
Type = 1, // regarded as the const
SubType = 0,
DivSeq = 0
C2CCmd = 0
},
Body = new MessageBody { RichText = new RichText { Elems = new List<Elem>() } },
ClientSequence = chain.ClientSequence,
Expand Down Expand Up @@ -224,13 +224,13 @@ public static MessageChain ParsePrivateFile(PushMsgBody message)
{
Type = (uint)(chain.IsGroup ? 82 : 9),
SubType = chain.IsGroup ? null : 4,
DivSeq = chain.IsGroup ? null : 4,
MsgId = (uint)(chain.MessageId & 0xFFFFFFFF),
C2CCmd = chain.IsGroup ? null : 4,
Random = (uint)(chain.MessageId & 0xFFFFFFFF),
Sequence = (uint?)Random.Shared.Next(1000000, 9999999),
Timestamp = (chain.Time == default ? DateTimeOffset.Now : new(chain.Time)).ToUnixTimeSeconds(),
Field7 = 1,
Field8 = 0,
Field9 = 0,
PkgNum = 1,
PkgIndex = 0,
DivSeq = 0,
Forward = new ForwardHead
{
Field1 = 0,
Expand All @@ -251,16 +251,16 @@ private static MessageChain ParseChain(PushMsgBody message)
message.ResponseHead.ToUid ?? string.Empty,
message.ResponseHead.FromUid ?? string.Empty,
message.ResponseHead.ToUin,
message.ContentHead.FriendSequence ?? 0,
message.ContentHead.NTMsgSeq ?? 0,
message.ContentHead.Sequence ?? 0,
message.ContentHead.NewId ?? 0,
message.ContentHead.MsgUid ?? 0,
message.ContentHead.Type == 141 ? MessageChain.MessageType.Temp : MessageChain.MessageType.Friend)

: new MessageChain(
message.ResponseHead.Grp.GroupUin,
message.ResponseHead.FromUin,
message.ContentHead.Sequence ?? 0,
message.ContentHead.NewId ?? 0);
message.ContentHead.MsgUid ?? 0);

if (message.Body?.RichText?.Elems is { } elems) chain.Elements.AddRange(elems);

Expand Down

0 comments on commit f9db6de

Please sign in to comment.