File tree Expand file tree Collapse file tree
Lagrange.Core/Internal/Packets/Message Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,26 @@ internal class ContentHead
1515
1616 [ ProtoMember ( 4 ) ] public long ? Random { get ; set ; }
1717
18- [ ProtoMember ( 5 ) ] public uint ? Sequence { get ; set ; }
18+ [ ProtoMember ( 5 ) ]
19+ private ulong ? _sequenceForProto { get ; set ; } // 这个字段专门给 Protobuf-net 使用
20+
21+ /// <summary>
22+ /// 消息序列号 (注意:如果服务器下发的值超过uint.MaxValue,这里会得到一个不正确的回绕值)
23+ /// </summary>
24+ public uint ? Sequence
25+ {
26+ get
27+ {
28+ if ( _sequenceForProto == null ) return null ;
29+
30+ // 强制转换,这里就是可能导致数据错误的地方
31+ return unchecked ( ( uint ) _sequenceForProto . Value ) ;
32+ }
33+ set
34+ {
35+ _sequenceForProto = value ;
36+ }
37+ }
1938
2039 [ ProtoMember ( 6 ) ] public long ? Timestamp { get ; set ; }
2140
@@ -32,4 +51,4 @@ internal class ContentHead
3251 [ ProtoMember ( 12 ) ] public ulong ? MsgUid { get ; set ; }
3352
3453 [ ProtoMember ( 15 ) ] public ForwardHead ? Forward { get ; set ; }
35- }
54+ }
You can’t perform that action at this time.
0 commit comments