~ruther/NosTale-PacketLogger

ref: 1ac87d8e49a6ebb1fa3b619a0538dc828ab7fd73 NosTale-PacketLogger/src/PacketLogger/Models/Packets/CommsPacketProvider.cs -rw-r--r-- 1.4 KiB
1ac87d8e — Rutherther feat: add pcap support 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
//  CommsPacketProvider.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;
using System.ComponentModel;
using System.Data;
using System.Threading;
using System.Threading.Tasks;
using DynamicData;
using DynamicData.Binding;
using NosSmooth.Comms.Local;
using NosSmooth.Core.Packets;
using NosSmooth.PacketSerializer.Abstractions.Attributes;
using ReactiveUI;
using Remora.Results;

namespace PacketLogger.Models.Packets;

/// <summary>
/// A packet provider using a connection to a nostale client.
/// </summary>
public class CommsPacketProvider : ClientPacketProvider
{
    private readonly Comms _comms;
    private long _currentIndex;

    /// <summary>
    /// Initializes a new instance of the <see cref="CommsPacketProvider"/> class.
    /// </summary>
    /// <param name="process">The process.</param>
    /// <param name="comms">The comms.</param>
    public CommsPacketProvider(NostaleProcess process, Comms comms)
        : base(process, comms.Client)
    {
        _comms = comms;
    }

    /// <inheritdoc />
    public override bool IsOpen => _comms.Connection.Connection.State == ConnectionState.Open;

    /// <inheritdoc />
    public override Task<Result> Close()
    {
        _comms.Connection.Connection.Disconnect();
        return Task.FromResult(Result.FromSuccess());
    }
}
Do not follow this link