Skip to content

Commit b80c6b1

Browse files
committed
[修改]1. 修改消息头的长度为sizeof 计算
1 parent f95d8f7 commit b80c6b1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Runtime/Network/Helper/DefaultPacketReceiveHeaderHandler.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@ public bool Handler(object source)
6363
/// <summary>
6464
/// 网络包长度
6565
/// </summary>
66-
private const int NetPacketLength = 2;
66+
private const int NetPacketLength = sizeof(uint);
6767

6868
/// <summary>
6969
/// 操作消息类型
7070
/// </summary>
71-
private const int OperationTypeLength = 1;
71+
private const int OperationTypeLength = sizeof(byte);
7272

7373
/// <summary>
7474
/// 消息压缩标记长度
7575
/// </summary>
76-
private const int NetZipFlagLength = 1;
76+
private const int NetZipFlagLength = sizeof(byte);
7777

7878
/// <summary>
7979
/// 消息码
8080
/// </summary>
81-
private const int NetCmdIdLength = 4;
81+
private const int NetCmdIdLength = sizeof(int);
8282

8383
/// <summary>
8484
/// 消息编号
8585
/// </summary>
86-
private const int NetUniqueIdLength = 4;
86+
private const int NetUniqueIdLength = sizeof(int);
8787

8888
/// <summary>
8989
/// 包头长度 2 + 1 + 1 + 4 + 4

Runtime/Network/Helper/DefaultPacketSendHeaderHandler.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ public class DefaultPacketSendHeaderHandler : IPacketSendHeaderHandler, IPacketH
1212
/// <summary>
1313
/// 网络包长度
1414
/// </summary>
15-
private const int NetPacketLength = 2;
15+
private const int NetPacketLength = sizeof(uint);
1616

1717
/// <summary>
1818
/// 消息码
1919
/// </summary>
20-
private const int NetCmdIdLength = 4;
20+
private const int NetCmdIdLength = sizeof(int);
2121

2222
/// <summary>
2323
/// 消息操作类型长度
2424
/// </summary>
25-
private const int NetOperationTypeLength = 1;
25+
private const int NetOperationTypeLength = sizeof(byte);
2626

2727
/// <summary>
2828
/// 消息压缩标记长度
2929
/// </summary>
30-
private const int NetZipFlagLength = 1;
30+
private const int NetZipFlagLength = sizeof(byte);
3131

3232
/// <summary>
3333
/// 消息编号
3434
/// </summary>
35-
private const int NetUniqueIdLength = 4;
35+
private const int NetUniqueIdLength = sizeof(int);
3636

3737

3838
public DefaultPacketSendHeaderHandler()
3939
{
40-
// 2 + 1 + 1 + 4 + 4
40+
// 4 + 1 + 1 + 4 + 4
4141
PacketHeaderLength = NetPacketLength + NetOperationTypeLength + NetZipFlagLength + NetUniqueIdLength + NetCmdIdLength;
4242
m_CachedByte = new byte[PacketHeaderLength];
4343
}

0 commit comments

Comments
 (0)