コード例 #1
0
        /// <summary>
        /// Enqueues a serialized event directly into the send buffer for this <see cref="BroConnection"/>.
        /// </summary>
        /// <param name="data">Serialized event.</param>
        /// <param name="length">Length of serialized event.</param>
        /// <returns><c>true</c> if successful; otherwise, <c>false</c>.</returns>
        /// <remarks>
        /// Enqueues the given event data into the transmit buffer of this <see cref="BroConnection"/>.
        /// <paramref name="length"/> bytes of <paramref name="data"/> must correspond to a single event.
        /// </remarks>
        /// <exception cref="ArgumentNullException"><paramref name="data"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="length"/> is larger than <paramref name="data"/> length.</exception>
        /// <exception cref="ObjectDisposedException">Cannot send event, <see cref="BroConnection"/> is disposed.</exception>
        public bool SendEvent(byte[] data, int length)
        {
            if ((object)data == null)
            {
                throw new ArgumentNullException("data");
            }

            if (length > data.Length)
            {
                throw new ArgumentOutOfRangeException("length");
            }

            if (m_connectionPtr.IsInvalid())
            {
                throw new ObjectDisposedException("Cannot send event, Bro connection is disposed.");
            }

            return(BroApi.bro_event_send_raw(m_connectionPtr, data, length) != 0);
        }