private bool toRead() { if (!read()) { return(false); } if (_length == _buf.Length) { clean(); //依然没位置 if (_length == _buf.Length) { Ctrl.warnLogForIO("超出预设buffer大小(单包超上限)", _buf.Length); grow(_buf.Length << 1); // if(ShineSetting.needGrowOnByteLimit) // { // grow(_buf.Length<<1); // } // else // { // onError("单包超上限,强制关闭连接"); // return false; // } } } return(true); }
private bool toKCPReceive(int len) { int resInput = _kcp.Input(new Span <byte>(_receiveCache, 0, len)); if (resInput < 0) { Ctrl.warnLogForIO("ukcp input fail. res:" + resInput); return(false); } int ps = _kcp.PeekSize(); while (ps > 0) { if (ps > _receiveCach2.Length) { Ctrl.warnLogForIO("kcp Receive时,_receiveCach2超出预设尺寸", ps); _receiveCach2 = new byte[ps]; } int ps2 = _kcp.Recv(_receiveCach2); if (ps2 > 0) { _receiveBuffer.append(_receiveCach2, 0, ps2); ps = _kcp.PeekSize(); } else { Ctrl.warnLogForIO("ukcp recv fail. res:" + resInput); return(false); } } return(true); }