// // INostaleClient.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 NosCore.Packets.Interfaces; using NosSmooth.Core.Commands; using Remora.Results; namespace NosSmooth.Core.Client; /// /// Class representing nostale client that may send and receive packets as well as process commands. /// public interface INostaleClient { /// /// Starts the client. /// /// A cancellation token for stopping the client. /// The result that may or may not have succeeded. public Task RunAsync(CancellationToken stopRequested = default); /// /// Sends the given packet to the server. /// /// The packet to send. /// The cancellation token for cancelling the operation. /// A result that may or may not have succeeded. public Task SendPacketAsync(IPacket packet, CancellationToken ct = default); /// /// Sends the given raw packet string. /// /// The packed string to send in plain text. /// The cancellation token for cancelling the operation. /// A result that may or may not have succeeded. public Task SendPacketAsync(string packetString, CancellationToken ct = default); /// /// Receives the given raw packet string. /// /// The packet to receive in plain text. /// The cancellation token for cancelling the operation. /// A result that may or may not have succeeded. public Task ReceivePacketAsync(string packetString, CancellationToken ct = default); /// /// Receives the given packet. /// /// The packet to receive. /// The cancellation token for cancelling the operation. /// A result that may or may not have succeeded. public Task ReceivePacketAsync(IPacket packet, CancellationToken ct = default); /// /// Sends the given command to the client. /// /// /// Commands can be used for doing complex operations like walking that require sending multiple packets /// and/or calling some functions of the local client. /// This method will not return until the command is finished or it failed. /// /// The command to send. /// The cancellation token for cancelling the operation. /// A result that may or may not have succeeded. public Task SendCommandAsync(ICommand command, CancellationToken ct = default); }