提交 01b9ac54 编写于 作者: T tanghai

增加kcp发送消息阻塞消息的检查,超过两倍发送窗口就应该断开连接

上级 d7a59ad7
......@@ -33,6 +33,7 @@ namespace ETModel
public const int ERR_PeerDisconnect = 202008;
public const int ERR_SocketCantSend = 202009;
public const int ERR_SocketError = 202010;
public const int ERR_KcpWaitSendSizeTooLarge = 202011;
public const int ERR_WebsocketPeerReset = 203001;
public const int ERR_WebsocketMessageTooBig = 203002;
......
......@@ -283,11 +283,11 @@ namespace ETModel
}
// 超时断开连接
if (timeNow - this.lastRecvTime > 40 * 1000)
{
this.OnError(ErrorCode.ERR_KcpChannelTimeout);
return;
}
//if (timeNow - this.lastRecvTime > 40 * 1000)
//{
// this.OnError(ErrorCode.ERR_KcpChannelTimeout);
// return;
//}
try
{
......@@ -425,6 +425,13 @@ namespace ETModel
public override void Send(MemoryStream stream)
{
// 检查等待发送的消息,如果超出两倍窗口大小,应该断开连接
if (Kcp.KcpWaitsnd(this.kcp) > 256 * 2)
{
this.OnError(ErrorCode.ERR_KcpWaitSendSizeTooLarge);
return;
}
ushort size = (ushort)(stream.Length - stream.Position);
byte[] bytes;
if (this.isConnected)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册