~ruther/NosSmooth

ref: 197af02c063ffa7944c1a60a816bbf52277a0d4f NosSmooth/Core/NosSmooth.Core/Commands/Control/ControlCommandPacketResponders.cs -rw-r--r-- 1.2 KiB
197af02c — Rutherther fix(core): cancel control command cancellation token every time 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
//  ControlCommandPacketResponders.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.Walking;
using NosSmooth.Core.Packets;
using NosSmooth.Packets.Client.Movement;
using NosSmooth.Packets.Server.Maps;
using Remora.Results;

namespace NosSmooth.Core.Commands.Control;

/// <summary>
/// Packet responder for cancellation of <see cref="TakeControlCommand"/>.
/// </summary>
public class ControlCommandPacketResponders : IPacketResponder<CMapPacket>
{
    private readonly ControlCommands _controlCommands;

    /// <summary>
    /// Initializes a new instance of the <see cref="ControlCommandPacketResponders"/> class.
    /// </summary>
    /// <param name="controlCommands">The control commands.</param>
    public ControlCommandPacketResponders(ControlCommands controlCommands)
    {
        _controlCommands = controlCommands;
    }

    /// <inheritdoc />
    public Task<Result> Respond(PacketEventArgs<CMapPacket> packet, CancellationToken ct = default)
        => _controlCommands.CancelAsync(ControlCommandsFilter.MapChangeCancellable, ct: ct);
}
Do not follow this link