2025-01-17 08:53:44 +00:00
|
|
|
using System;
|
2025-01-18 16:47:36 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2025-01-17 08:53:44 +00:00
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using RaiNote.PacketMediator;
|
|
|
|
|
|
|
|
namespace PacketMediator.Generator.Sample;
|
|
|
|
|
|
|
|
public enum OperationCode {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
D,
|
|
|
|
E = 10,
|
|
|
|
F,
|
|
|
|
G,
|
|
|
|
H = 100,
|
2025-01-18 16:47:36 +00:00
|
|
|
I = 5000,
|
2025-01-17 08:53:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[GamePacketId(OperationCode.A)]
|
|
|
|
public struct StructA : IIncomingPacket {
|
|
|
|
public void Deserialize(byte[] data) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[GamePacketId(OperationCode.B)]
|
2025-01-18 16:47:36 +00:00
|
|
|
public struct StructB : IPacket, IIncomingPacket {
|
|
|
|
public void Deserialize(byte[] data) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
2025-01-17 08:53:44 +00:00
|
|
|
}
|
2025-01-18 16:47:36 +00:00
|
|
|
|
2025-01-17 08:53:44 +00:00
|
|
|
[GamePacketId(OperationCode.E)]
|
2025-01-18 16:47:36 +00:00
|
|
|
public struct StructC : IIncomingPacket {
|
|
|
|
public void Deserialize(byte[] data) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
2025-01-17 08:53:44 +00:00
|
|
|
}
|
2025-01-18 16:47:36 +00:00
|
|
|
|
|
|
|
[GamePacketId(OperationCode.H)]
|
|
|
|
public struct StructD : IIncomingPacket {
|
|
|
|
public void Deserialize(byte[] data) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
2025-01-17 08:53:44 +00:00
|
|
|
}
|
|
|
|
|
2025-01-18 16:47:36 +00:00
|
|
|
|
2025-01-17 08:53:44 +00:00
|
|
|
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false)]
|
|
|
|
public class GamePacketIdAttribute : PacketIdAttribute<OperationCode> {
|
|
|
|
public GamePacketIdAttribute(OperationCode code) : base(code) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class RandomSession {
|
|
|
|
}
|
|
|
|
|
|
|
|
public class HandlerA : IPacketHandler<StructA, RandomSession> {
|
|
|
|
public async Task HandleAsync(StructA packet, RandomSession session, CancellationToken cancellationToken) {
|
|
|
|
await Task.Delay(2000, cancellationToken);
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
2025-01-18 16:47:36 +00:00
|
|
|
|
|
|
|
public class TestHandler : IPacketHandler<StructB, RandomSession> {
|
|
|
|
public Task HandleAsync(StructB packet, RandomSession session, CancellationToken cancellationToken) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class BHandler : IPacketHandler<StructC, RandomSession> {
|
|
|
|
public Task HandleAsync(StructC packet, RandomSession session, CancellationToken cancellationToken) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class DHandler : IPacketHandler<StructD, RandomSession> {
|
|
|
|
public Task HandleAsync(StructD packet, RandomSession session, CancellationToken cancellationToken) {
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|