//
// BaseNostaleClient.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.Threading;
using System.Threading.Tasks;
using NosSmooth.Core.Commands;
using NosSmooth.Packets;
using NosSmooth.PacketSerializer;
using Remora.Results;
namespace NosSmooth.Core.Client;
///
/// Represents base class of .
///
///
/// This class serializes packets and processes commands.
///
public abstract class BaseNostaleClient : INostaleClient
{
private readonly CommandProcessor _commandProcessor;
///
/// Initializes a new instance of the class.
///
/// The command processor.
protected BaseNostaleClient
(
CommandProcessor commandProcessor
)
{
_commandProcessor = commandProcessor;
}
///
public abstract Task RunAsync(CancellationToken stopRequested = default);
///
public abstract Task SendPacketAsync(string packetString, CancellationToken ct = default);
///
public abstract Task ReceivePacketAsync(string packetString, CancellationToken ct = default);
///
public Task SendCommandAsync(ICommand command, CancellationToken ct = default)
=> _commandProcessor.ProcessCommand(this, command, ct);
}