~ruther/NosSmooth

d0d6eae78f41999438b9cd7564265139c2edf0be — Rutherther 2 years ago 3021286
feat(pcap): add running indication to pcap nostale client so it won't be run multiple times
1 files changed, 10 insertions(+), 0 deletions(-)

M Pcap/NosSmooth.Pcap/PcapNostaleClient.cs
M Pcap/NosSmooth.Pcap/PcapNostaleClient.cs => Pcap/NosSmooth.Pcap/PcapNostaleClient.cs +10 -0
@@ 39,6 39,7 @@ public class PcapNostaleClient : BaseNostaleClient
    private int _localPort;
    private long _localAddr;
    private CancellationToken? _stoppingToken;
    private bool _running;

    /// <summary>
    /// Initializes a new instance of the <see cref="PcapNostaleClient"/> class.


@@ 74,6 75,13 @@ public class PcapNostaleClient : BaseNostaleClient
    /// <inheritdoc />
    public override async Task<Result> RunAsync(CancellationToken stopRequested = default)
    {
        if (_running)
        {
            return Result.FromSuccess();
        }

        _running = true;

        _stoppingToken = stopRequested;
        TcpConnection? lastConnection = null;
        TcpConnection? reverseLastConnection = null;


@@ 150,6 158,8 @@ public class PcapNostaleClient : BaseNostaleClient
            {
                _pcapManager.UnregisterConnection(reverseLastConnection.Value);
            }

            _running = false;
        }

        return Result.FromSuccess();

Do not follow this link