Skip to content

Commit dc29a64

Browse files
authored
Merge pull request #11 from mostevercxz/master
修复客户端 Bundle 发送数据出错,导致服务器收到错误的 msgID,将玩家踢下线的问题。
2 parents 17736a5 + 6165c42 commit dc29a64

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

Bundle.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
public class Bundle : ObjectPool<Bundle>
1414
{
15-
public MemoryStream stream = new MemoryStream();
15+
public MemoryStream stream = MemoryStream.createObject();
1616
public List<MemoryStream> streamList = new List<MemoryStream>();
1717
public int numMessage = 0;
1818
public int messageLength = 0;
@@ -23,22 +23,11 @@ public Bundle()
2323
{
2424
}
2525

26-
public void clear()
27-
{
28-
stream = MemoryStream.createObject();
29-
streamList = new List<MemoryStream>();
30-
numMessage = 0;
31-
messageLength = 0;
32-
msgtype = null;
33-
_curMsgStreamIndex = 0;
34-
}
35-
3626
/// <summary>
3727
/// 把自己放回缓冲池
3828
/// </summary>
3929
public void reclaimObject()
40-
{
41-
clear();
30+
{
4231
reclaimObject(this);
4332
}
4433

@@ -101,8 +90,8 @@ public void send(NetworkInterface networkInterface)
10190
{
10291
for(int i=0; i<streamList.Count; i++)
10392
{
104-
stream = streamList[i];
105-
networkInterface.send(stream);
93+
MemoryStream tempStream = streamList[i];
94+
networkInterface.send(tempStream);
10695
}
10796
}
10897
else

0 commit comments

Comments
 (0)