~ruther/NosSmooth

ref: 24c8d2cc70193b8d82a830337060e0aba50f6867 NosSmooth/Samples/PacketInterceptor/DummyNostaleClient.cs -rw-r--r-- 1.3 KiB
24c8d2cc — František Boháček chore: add stylecop, ensure stylecop rules are met 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
37
38
using NosCore.Packets;
using NosCore.Packets.ServerPackets.MiniMap;
using NosSmooth.Core.Client;
using NosSmooth.Core.Commands;
using NosSmooth.Core.Packets;
using Remora.Results;

namespace PacketInterceptor;

public class DummyNostaleClient : BaseNostaleClient
{
    private readonly IPacketHandler _packetHandler;

    public DummyNostaleClient(CommandProcessor commandProcessor, IPacketSerializer packetSerializer,
        IPacketHandler packetHandler) : base(commandProcessor, packetSerializer)
    {
        _packetHandler = packetHandler;
    }

    public override async Task<Result> RunAsync(CancellationToken stopRequested = default)
    {
        await _packetHandler.HandleSentPacketAsync(new CMapPacket()
            { Header = "t", Id = 2, IsValid = true, KeepAliveId = 123, MapType = true, Type = 0 }, stopRequested);
        return Result.FromSuccess();
    }

    public override Task<Result> SendPacketAsync(string packetString, CancellationToken ct = default)
    {
        Console.WriteLine($"Sending packet {packetString}");
        return Task.FromResult(Result.FromSuccess());
    }

    public override Task<Result> ReceivePacketAsync(string packetString, CancellationToken ct = default)
    {
        Console.WriteLine($"Receiving packet {packetString}");
        return Task.FromResult(Result.FromSuccess());
    }
}
Do not follow this link