Example #1
0
        /// <summary>
        /// Resizes packet data length
        /// </summary>
        /// <param name="dataLength">New data length</param>
        /// <remarks>
        /// <see cref="Data"/> becomes invalid after calling this method.
        /// </remarks>
        public void Resize(int dataLength)
        {
            if (dataLength < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(dataLength));
            }

            ThrowIfNull();

            if (LibENet.PacketResize(m_Native, unchecked ((UIntPtr)dataLength)) < 0)
            {
                ThrowHelper.ThrowENetPacketResizeFailed();
            }
        }