using System; namespace CryptoExchange.Net.Sockets { /// /// Socket subscription /// public class SocketSubscription { /// /// Subscription id /// public int Id { get; } /// /// Exception event /// public event Action? Exception; /// /// Message handlers for this subscription. Should return true if the message is handled and should not be distributed to the other handlers /// public Action MessageHandler { get; set; } /// /// Request object /// public object? Request { get; set; } /// /// Subscription identifier /// public string? Identifier { get; set; } /// /// Is user subscription or generic /// public bool UserSubscription { get; set; } /// /// If the subscription has been confirmed /// public bool Confirmed { get; set; } private SocketSubscription(int id, object? request, string? identifier, bool userSubscription, Action dataHandler) { Id = id; UserSubscription = userSubscription; MessageHandler = dataHandler; Request = request; Identifier = identifier; } /// /// Create SocketSubscription for a request /// /// /// /// /// /// public static SocketSubscription CreateForRequest(int id, object request, bool userSubscription, Action dataHandler) { return new SocketSubscription(id, request, null, userSubscription, dataHandler); } /// /// Create SocketSubscription for an identifier /// /// /// /// /// /// public static SocketSubscription CreateForIdentifier(int id, string identifier, bool userSubscription, Action dataHandler) { return new SocketSubscription(id, null, identifier, userSubscription, dataHandler); } /// /// Invoke the exception event /// /// public void InvokeExceptionHandler(Exception e) { Exception?.Invoke(e); } } }