mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-07 16:06:15 +00:00
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using CryptoExchange.Net.Objects;
|
|
using CryptoExchange.Net.Objects.Sockets;
|
|
using CryptoExchange.Net.Sockets.MessageParsing.Interfaces;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace CryptoExchange.Net.Sockets
|
|
{
|
|
/// <summary>
|
|
/// A system subscription
|
|
/// </summary>
|
|
public abstract class SystemSubscription : Subscription
|
|
{
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
/// <param name="logger"></param>
|
|
/// <param name="authenticated"></param>
|
|
public SystemSubscription(ILogger logger, bool authenticated = false) : base(logger, authenticated, false)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override Query? GetSubQuery(SocketConnection connection) => null;
|
|
|
|
/// <inheritdoc />
|
|
public override Query? GetUnsubQuery() => null;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public abstract class SystemSubscription<T> : SystemSubscription
|
|
{
|
|
/// <inheritdoc />
|
|
public override Type GetMessageType(IMessageAccessor message) => typeof(T);
|
|
|
|
/// <inheritdoc />
|
|
public override Task<CallResult> DoHandleMessageAsync(SocketConnection connection, DataEvent<object> message)
|
|
=> HandleMessageAsync(connection, message.As((T)message.Data));
|
|
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
/// <param name="logger"></param>
|
|
/// <param name="authenticated"></param>
|
|
protected SystemSubscription(ILogger logger, bool authenticated) : base(logger, authenticated)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Handle an update message
|
|
/// </summary>
|
|
/// <param name="connection"></param>
|
|
/// <param name="message"></param>
|
|
/// <returns></returns>
|
|
public abstract Task<CallResult> HandleMessageAsync(SocketConnection connection, DataEvent<T> message);
|
|
}
|
|
}
|