chore: file header adjustment

This commit is contained in:
Timothy Schenk 2024-02-07 16:40:36 +01:00
parent 6147a76d16
commit 7ac4c8c0ef
Signed by: rainote
SSH key fingerprint: SHA256:pnkNSDwpAnaip00xaZlVFHKKsS7T8UtOomMzvs0yITE
95 changed files with 281 additions and 264 deletions

View file

@ -23,10 +23,13 @@ indent_style = space
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
file_header_template = Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
[*.(yaml|yml)]
indent_size = 2
[*.cs]
dotnet_diagnostic.MA0004.severity = none
file_header_template = Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
indent_size = 4
dotnet_sort_system_directives_first = true
dotnet_diagnostic.MA0007.severity = none

View file

@ -17,3 +17,8 @@ repos:
hooks:
- id: hadolint-docker
args: [--ignore, SC2086]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Security.Cryptography;
using BenchmarkDotNet.Attributes;
@ -13,14 +13,14 @@ namespace Benchmarks;
[Config(typeof(GenericConfig))]
public class Argon2Benchmarks
{
private byte[] _additionalData = null!;
[Params(2, 4)] public int _iterations;
[Params(16)] public int _length;
[Params(16, 32)] public int _memory;
[Params(1, 2)] public int _parallelism;
private byte[] _salt = null!;
private byte[] _additionalData = null!;
[Params(16)] public int _length;
private byte[] _password = null!;
private byte[] _salt = null!;
[GlobalSetup]
public void Setup()
@ -39,7 +39,7 @@ public class Argon2Benchmarks
MemorySize = 1024 * _memory,
DegreeOfParallelism = _parallelism,
AssociatedData = _additionalData,
Salt = _salt,
Salt = _salt
}.GetBytes(_length);
}
@ -52,7 +52,7 @@ public class Argon2Benchmarks
MemorySize = 1024 * _memory,
DegreeOfParallelism = _parallelism,
AssociatedData = _additionalData,
Salt = _salt,
Salt = _salt
}.GetBytes(_length);
}
@ -65,7 +65,7 @@ public class Argon2Benchmarks
MemorySize = 1024 * _memory,
DegreeOfParallelism = _parallelism,
AssociatedData = _additionalData,
Salt = _salt,
Salt = _salt
}.GetBytes(_length);
}
@ -82,7 +82,7 @@ public class Argon2Benchmarks
HashLength = _length,
Salt = _salt,
AssociatedData = _additionalData,
Password = _password,
Password = _password
};
var argon2 = new Argon2(config);
return argon2.Hash().Buffer;
@ -101,7 +101,7 @@ public class Argon2Benchmarks
HashLength = _length,
Salt = _salt,
AssociatedData = _additionalData,
Password = _password,
Password = _password
};
var argon2 = new Argon2(config);
return argon2.Hash().Buffer;
@ -120,7 +120,7 @@ public class Argon2Benchmarks
HashLength = _length,
Salt = _salt,
AssociatedData = _additionalData,
Password = _password,
Password = _password
};
var argon2 = new Argon2(config);
return argon2.Hash().Buffer;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary;
using System.Security.Cryptography;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Collections.Concurrent;
using System.Collections.Immutable;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using BenchmarkDotNet.Analysers;
using BenchmarkDotNet.Columns;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Reflection;
using BenchmarkDotNet.Running;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Net.Sockets;
using Continuity.AuthServer.Packets;
@ -12,8 +12,8 @@ namespace Continuity.AuthServer;
public class AuthSession : TcpSession
{
private readonly ILogger<AuthSession> _logger;
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
private readonly ILogger<AuthSession> _logger;
private readonly IMediator _mediator;
public AuthSession(TcpServer

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Security.Cryptography;
using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Diagnostics;
using Continuity.AuthServer.Packets;
@ -12,9 +12,8 @@ namespace Continuity.AuthServer.Consumers;
[UsedImplicitly]
public class PacketConsumer : IConsumer<RawPacket>, IDisposable
{
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
private readonly ActivitySource _activitySource;
private readonly PacketDistributorService<OperationCode, AuthSession> _distributorService;
public PacketConsumer(PacketDistributorService<OperationCode, AuthSession> distributorService)
{

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Continuity.AuthServer.DB.Documents;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Continuity.AuthServer.DB.Documents;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
#nullable disable

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
#nullable disable

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Microsoft.EntityFrameworkCore.Migrations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB.Documents;
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.PacketHandlers;
using Microsoft.Extensions.Logging;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB.Documents;
using Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB;
using Continuity.AuthServer.DB.Documents;
@ -27,11 +27,12 @@ public partial class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPa
var guildNameResponsePacket = new CharacterSelectionSetGuildNamePacket { GuildNames = Array.Empty<string>() };
var accountExists =
await _wonderkingContext.Accounts.AsNoTracking().AnyAsync(a => a.Id == session.AccountId, cancellationToken: cancellationToken);
await _wonderkingContext.Accounts.AsNoTracking()
.AnyAsync(a => a.Id == session.AccountId, cancellationToken);
var amountOfCharacter = await _wonderkingContext.Characters.AsNoTracking().Include(c => c.Account)
.Where(c => c.Account.Id == session.AccountId).Take(3)
.CountAsync(cancellationToken: cancellationToken);
.CountAsync(cancellationToken);
if (!accountExists)
{
@ -52,7 +53,7 @@ public partial class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPa
await _wonderkingContext.Characters.AsNoTracking().Include(c => c.Account).Include(c => c.GuildMember)
.ThenInclude(gm => gm.Guild)
.Where(c => c.Account.Id == session.AccountId && c.GuildMember.Guild != null)
.Select(c => c.GuildMember.Guild.Name).Take(3).ToArrayAsync(cancellationToken: cancellationToken);
.Select(c => c.GuildMember.Guild.Name).Take(3).ToArrayAsync(cancellationToken);
}
else
{

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB;
using Continuity.AuthServer.DB.Documents;
@ -30,8 +30,8 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket,
public async Task HandleAsync(CharacterCreationPacket packet, AuthSession session,
CancellationToken cancellationToken)
{
var account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Id == session.AccountId, cancellationToken: cancellationToken);
var account =
await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Id == session.AccountId, cancellationToken);
if (account is null)
{
@ -93,7 +93,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket,
private static Character CreateDefaultCharacter(CharacterCreationPacket packet, Account account,
InventoryItem[] items, JobSpecificMapping firstJobConfig)
{
return new Character()
return new Character
{
Account = account,
MapId = 300,

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB;
using Microsoft.EntityFrameworkCore;
@ -17,10 +17,11 @@ public class CharacterDeletionHandler : IPacketHandler<CharacterDeletePacket, Au
_wonderkingContext = wonderkingContext;
}
public async Task HandleAsync(CharacterDeletePacket packet, AuthSession session, CancellationToken cancellationToken)
public async Task HandleAsync(CharacterDeletePacket packet, AuthSession session,
CancellationToken cancellationToken)
{
var character = await _wonderkingContext.Characters.FirstOrDefaultAsync(x => x.Name == packet.Name &&
x.Account.Id == session.AccountId, cancellationToken: cancellationToken);
x.Account.Id == session.AccountId, cancellationToken);
var response = new CharacterDeleteResponsePacket { HasToBeZero = 0 };
if (character == null)

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Continuity.AuthServer.DB;
using Microsoft.EntityFrameworkCore;
@ -22,7 +22,7 @@ public class CharacterNameCheckHandler : IPacketHandler<CharacterNameCheckPacket
{
var isTaken =
await _wonderkingContext.Characters.AnyAsync(c => c.Name == packet.Name,
cancellationToken: cancellationToken);
cancellationToken);
var responsePacket = new CharacterNameCheckPacketResponse { IsTaken = isTaken };
await session.SendAsync(responsePacket);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Diagnostics;
using System.Security.Cryptography;
@ -19,10 +19,10 @@ namespace Continuity.AuthServer.PacketHandlers;
public class LoginHandler : IPacketHandler<LoginInfoPacket, AuthSession>
{
private static readonly ActivitySource _activitySource = new(nameof(Server));
private readonly IConfiguration _configuration;
private readonly ILogger<LoginHandler> _logger;
private readonly WonderkingContext _wonderkingContext;
private static readonly ActivitySource _activitySource = new(nameof(Server));
public LoginHandler(ILogger<LoginHandler> logger, WonderkingContext wonderkingContext, IConfiguration configuration)
{
@ -35,14 +35,17 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket, AuthSession>
{
LoginResponseReason loginResponseReason;
_logger.LoginData(packet.Username, packet.Password);
var account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username, cancellationToken: cancellationToken);
var account =
await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username,
cancellationToken);
if (account == null)
{
if (_configuration.GetSection("Testing").GetValue<bool>("CreateAccountOnLogin"))
{
loginResponseReason = await CreateAccountOnLoginAsync(packet.Username, packet.Password);
account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username, cancellationToken: cancellationToken);
account = await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Username == packet.Username,
cancellationToken);
}
else
{

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using MassTransit;
using Wonderking.Packets;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Net;
using System.Reflection;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Collections.Concurrent;
using Continuity.AuthServer.DB.Documents;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Net;
using System.Net.Sockets;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Diagnostics;
using JetBrains.Annotations;
@ -6,11 +6,9 @@ using JetBrains.Annotations;
namespace Rai.PacketMediator;
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public interface IPacketHandler<in TIncomingPacket, in TSession> : IPacketHandler<TSession> where TIncomingPacket : IIncomingPacket
public interface IPacketHandler<in TIncomingPacket, in TSession> : IPacketHandler<TSession>
where TIncomingPacket : IIncomingPacket
{
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public Task HandleAsync(TIncomingPacket packet, TSession session, CancellationToken cancellationToken);
async Task<bool> IPacketHandler<TSession>.TryHandleAsync(IIncomingPacket packet, TSession session,
CancellationToken cancellationToken)
{
@ -20,12 +18,15 @@ public interface IPacketHandler<in TIncomingPacket, in TSession> : IPacketHandle
}
using var activity = new ActivitySource(nameof(PacketMediator)).StartActivity(nameof(HandleAsync));
activity?.AddTag("Handler", this.ToString());
activity?.AddTag("Handler", ToString());
activity?.AddTag("Packet", packet.ToString());
await HandleAsync(tPacket, session, cancellationToken);
return true;
}
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public Task HandleAsync(TIncomingPacket packet, TSession session, CancellationToken cancellationToken);
}
public interface IPacketHandler<in TSession>

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Collections.Concurrent;
using System.Collections.Immutable;
@ -15,12 +15,10 @@ public class PacketDistributor<TPacketIdEnum, TSession> where TPacketIdEnum : En
{
private readonly Channel<ValueTuple<byte[], TPacketIdEnum, TSession>> _channel;
private readonly ConcurrentDictionary<TPacketIdEnum, IPacketHandler<TSession>?> _packetHandlersInstantiation;
private readonly ImmutableDictionary<TPacketIdEnum,
Func<byte[], IIncomingPacket>> _deserializationMap;
public ImmutableDictionary<Type, TPacketIdEnum> PacketIdMap { get; }
private readonly ConcurrentDictionary<TPacketIdEnum, IPacketHandler<TSession>?> _packetHandlersInstantiation;
public PacketDistributor(IServiceProvider serviceProvider,
IEnumerable<Assembly> sourcesContainingPackets, IEnumerable<Assembly> sourcesContainingPacketHandlers)
@ -37,7 +35,7 @@ public class PacketDistributor<TPacketIdEnum, TSession> where TPacketIdEnum : En
var packetHandlers = GetAllPacketHandlersWithId(sourcesContainingPacketHandlers);
this.PacketIdMap = allOutgoingPackets.Select(x => new { PacketId = x.Key, Type = x.Value })
PacketIdMap = allOutgoingPackets.Select(x => new { PacketId = x.Key, Type = x.Value })
.ToImmutableDictionary(x => x.Type, x => x.PacketId);
var tempDeserializationMap =
@ -69,6 +67,8 @@ public class PacketDistributor<TPacketIdEnum, TSession> where TPacketIdEnum : En
_deserializationMap = tempDeserializationMap.ToImmutableDictionary();
}
public ImmutableDictionary<Type, TPacketIdEnum> PacketIdMap { get; }
private static IEnumerable<KeyValuePair<TPacketIdEnum, Type>> GetAllPackets(
IEnumerable<Assembly> sourcesContainingPackets, Type packetType)
{

View file

@ -1,10 +1,11 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Reflection;
using Microsoft.Extensions.Hosting;
namespace Rai.PacketMediator;
public class PacketDistributorService<TPacketIdEnum, TSession> : Microsoft.Extensions.Hosting.IHostedService
public class PacketDistributorService<TPacketIdEnum, TSession> : IHostedService
where TPacketIdEnum : Enum
{
private readonly PacketDistributor<TPacketIdEnum, TSession> _packetDistributor;
@ -21,20 +22,20 @@ public class PacketDistributorService<TPacketIdEnum, TSession> : Microsoft.Exten
return _packetDistributor.DequeuePacketAsync(cancellationToken);
}
public Task AddPacketAsync(byte[] packetData, TPacketIdEnum operationCode, TSession session)
{
return this._packetDistributor.AddPacketAsync(packetData, operationCode, session);
}
public Task StopAsync(CancellationToken cancellationToken)
{
return Task.CompletedTask;
}
public Task AddPacketAsync(byte[] packetData, TPacketIdEnum operationCode, TSession session)
{
return _packetDistributor.AddPacketAsync(packetData, operationCode, session);
}
public TPacketIdEnum GetOperationCodeByPacketType(IPacket packet)
{
var type = packet.GetType();
this._packetDistributor.PacketIdMap.TryGetValue(type, out var value);
_packetDistributor.PacketIdMap.TryGetValue(type, out var value);
if (value is null)
{
throw new ArgumentOutOfRangeException(type.Name);

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Game.Data.Item;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;
using Wonderking.Game.Data.Item;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Reflection;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
/* Nicht gemergte Änderung aus Projekt "Wonderking(net7.0)"
Vor:

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary;
using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Wonderking.Game.Data.Item;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text;
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text;
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text;
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text;
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Packets;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary;
using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary;
using System.Text;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator;
@ -8,6 +8,7 @@ namespace Wonderking.Packets.Outgoing;
public class CharacterNameCheckPacketResponse : IOutgoingPacket
{
public required bool IsTaken { get; set; }
public byte[] Serialize()
{
Span<byte> data = stackalloc byte[1];

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text;
using Rai.PacketMediator;
@ -9,6 +9,7 @@ namespace Wonderking.Packets.Outgoing;
public class CharacterSelectionSetGuildNamePacket : IOutgoingPacket
{
public required string[] GuildNames { get; set; }
public byte[] Serialize()
{
Span<byte> data = stackalloc byte[1 + (1 + 16 + 1) * GuildNames.Length];

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json.Serialization;
using JetBrains.Annotations;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Wonderking.Game.Data.Character;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
namespace Wonderking.Packets.Outgoing.Data;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Runtime.InteropServices;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Buffers.Binary;
using Rai.PacketMediator;
@ -14,6 +14,7 @@ public class LoginResponsePacket : IOutgoingPacket
public required bool IsGameMaster { get; set; }
public required ServerChannelData[] ChannelData { get; set; }
public byte[] Serialize()
{
const int sizeOfServerChannelData = 5;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using Rai.PacketMediator;

View file

@ -1,4 +1,4 @@
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
using System.Text.Json;
using System.Text.Json.Serialization;