/// <summary> /// Writes a sequence of bytes to the stream. /// </summary> /// <param name="buffer"> /// The buffer to write. /// </param> /// <param name="offset"> /// The offset within the buffer to write in to the stream. /// </param> /// <param name="count"> /// The maximum number of bytes to write. /// </param> /// <returns> /// The number of bytes written in to the stream. /// </returns> public override void Write(byte[] buffer, int offset, int count) { StreamWrite?.Invoke(this, new Memory <byte>(buffer, offset, count), out _dropConnection); CheckHandleDropFlag(); _innerStream.Write(buffer, offset, count); }
/// <summary> /// Reads a sequence of bytes from the stream. /// </summary> /// <param name="buffer"> /// The buffer to read in to. /// </param> /// <param name="offset"> /// The offset within the buffer to read in to. /// </param> /// <param name="count"> /// The maximum number of bytes to read. /// </param> /// <returns> /// The number of bytes read from the stream. /// </returns> public override int Read(byte[] buffer, int offset, int count) { var numRead = _innerStream.Read(buffer, offset, count); StreamRead?.Invoke(this, new Memory <byte>(buffer, offset, numRead), out _dropConnection); CheckHandleDropFlag(); return(numRead); }
/// <summary> /// Invokes the <seealso cref="StreamClosed" /> callback. /// </summary> public override void Close() { StreamClosed?.Invoke(this, new Memory <byte>(), out _dropConnection); base.Close(); }