/// <summary> /// add data from owner to buffer, and the sequence information to data sequence. /// </summary> /// <param name="owner"> /// an object that specifies the owner of data or event.<para/> /// if data, the length must not be null/byte[0].<para/> /// if event, it's a TransportEvent object and data must be byte[0]. /// </param> /// <param name="data"> /// a bytes array that contains the data.<para/> /// if event, it can be null. /// </param> /// <param name="buffer"> /// a BytesBuffer object that stores the data. /// </param> /// <exception cref="ObjectDisposedException"> /// thrown when this object is disposed. /// </exception> /// <exception cref="ArgumentNullException"> /// thrown when data is null. /// </exception> public void Add(object owner, byte[] data, BytesBuffer buffer) { if (disposed) { throw new ObjectDisposedException("DataSequence"); } if (data == null) { throw new ArgumentNullException("data"); } lock (this.objectLock) { // must add data to buffer, then add the sequence item to triggle received event. if (data.Length > 0) { buffer.Add(data); this.dataLength += data.Length; this.sequence.Add(new SequenceItem(owner, data.Length)); } else { this.sequence.Add(new SequenceItem(owner, 0)); } // if the owner in the search history, remove it to make it can be searched by user again. if (this.visitedOwners.Contains(owner)) { this.visitedOwners.Remove(owner); } this.receivedEvent.Set(); } }
/// <summary> /// add data from owner to buffer, and the sequence information to data sequence. /// </summary> /// <param name="owner"> /// an object that specifies the owner of data or event.<para/> /// if data, the length must not be null/byte[0].<para/> /// if event, it's a TransportEvent object and data must be byte[0]. /// </param> /// <param name="data"> /// a bytes array that contains the data.<para/> /// if event, it can be null. /// </param> /// <param name="buffer"> /// a BytesBuffer object that stores the data. /// </param> /// <exception cref="ObjectDisposedException"> /// thrown when this object is disposed. /// </exception> /// <exception cref="ArgumentNullException"> /// thrown when data is null. /// </exception> public void Add(object owner, byte[] data, BytesBuffer buffer) { if (disposed) { throw new ObjectDisposedException("DataSequence"); } if (data == null) { throw new ArgumentNullException("data"); } lock (this.objectLock) { // must add data to buffer, then add the sequence item to triggle received event. if (data.Length > 0) { buffer.Add(data); this.dataLength += data.Length; this.sequence.Add(new SequenceItem(owner, data.Length)); } else { this.sequence.Add(new SequenceItem(owner, 0)); } // if the owner in the search history, remove it to make it can be searched by user again. if (this.visitedOwners.Contains(owner)) { this.visitedOwners.Remove(owner); } this.receivedEvent.Set(); } }