// // IPacketProvider.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Threading; using System.Threading.Tasks; using DynamicData; using PacketLogger.Models.Filters; using Remora.Results; namespace PacketLogger.Models.Packets; /// /// Provides packets from some kind of a source. /// public interface IPacketProvider : INotifyPropertyChanged, IDisposable { /// /// Gets the name. /// public string Name { get; } /// /// Gets whether was called and successfully finished. /// public bool IsOpen { get; } /// /// Gets or sets whether to log received packets. /// public bool LogReceived { get; set; } /// /// Gets or sets whether to log sent pckets. /// public bool LogSent { get; set; } /// /// Gets the filtered packets from this provider. /// public SourceList Packets { get; } /// /// Open the provider/connection, load etc. /// /// A result that may or may not have succeeded. public Task Open(); /// /// Close the connection, dispose. /// /// A result that may or may not have succeeded. public Task Close(); /// /// Clear all packets. /// public void Clear(); /// /// Send the given packets. /// /// The packet to send. /// The cancellation token used for cancelling the operation. /// A result that may or may not have succeeded. Task SendPacket(string packetString, CancellationToken ct = default); /// /// Receive the given packet. /// /// The packet to send. /// The cancellation token used for cancelling the operation. /// A result that may or may not have succeeded. Task ReceivePacket(string packetString, CancellationToken ct = default); }