~ruther/NosSmooth

ref: 674cee15aaa8921e78e6935331e18278f055c36e NosSmooth/Core/NosSmooth.Core/Contracts/Responders/ContractPacketResponder.cs -rw-r--r-- 1.0 KiB
674cee15 — František Boháček feat(core): add basics of a contract system 2 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
//
//  ContractPacketResponder.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.Packets;
using NosSmooth.Packets;
using Remora.Results;

namespace NosSmooth.Core.Contracts.Responders;

/// <summary>
/// A responder that calls Contractor update.
/// </summary>
public class ContractPacketResponder : IEveryPacketResponder
{
    private readonly Contractor _contractor;

    /// <summary>
    /// Initializes a new instance of the <see cref="ContractPacketResponder"/> class.
    /// </summary>
    /// <param name="contractor">The contractor.</param>
    public ContractPacketResponder(Contractor contractor)
    {
        _contractor = contractor;
    }

    /// <inheritdoc />
    public Task<Result> Respond<TPacket>(PacketEventArgs<TPacket> packetArgs, CancellationToken ct = default)
        where TPacket : IPacket
        => _contractor.Update(packetArgs.Packet, ct);
}
Do not follow this link