void SendReliable(KcpHeader header, ArraySegment <byte> content) { // 1 byte header + content needs to fit into send buffer if (1 + content.Count <= kcpSendBuffer.Length) // TODO { // copy header, content (if any) into send buffer kcpSendBuffer[0] = (byte)header; if (content.Count > 0) { Buffer.BlockCopy(content.Array, content.Offset, kcpSendBuffer, 1, content.Count); } // send to kcp for processing int sent = kcp.Send(kcpSendBuffer, 0, 1 + content.Count); if (sent < 0) { Log.Warning($"Send failed with error={sent} for content with length={content.Count}"); } } // otherwise content is larger than MaxMessageSize. let user know! else { Log.Error($"Failed to send reliable message of size {content.Count} because it's larger than ReliableMaxMessageSize={ReliableMaxMessageSize}"); } }
public void Send(ArraySegment <byte> data) { // only allow sending up to MaxMessageSize sized messages. // other end won't process bigger messages anyway. if (data.Count <= Kcp.MTU_DEF) { int sent = kcp.Send(data.Array, data.Offset, data.Count); if (sent < 0) { Debug.LogWarning($"Send failed with error={sent} for segment with length={data.Count}"); } } else { Debug.LogError($"Failed to send message of size {data.Count} because it's larger than MaxMessageSize={Kcp.MTU_DEF}"); } }
public void Send(ArraySegment <byte> data) { kcp.Send(data.Array, data.Offset, data.Count); }