Projektdateien hinzufügen.
This commit is contained in:
1 parent
cbbf47885d
commit
2674eb2a10
32 files changed
+2091
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Drawing;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
public class BufferRental
|
||||
{
|
||||
private readonly ConcurrentQueue<byte[]> buffers = new ConcurrentQueue<byte[]>();
|
||||
private readonly int size;
|
||||
public BufferRental(int size)
|
||||
{
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public byte[] Rent()
|
||||
{
|
||||
if (buffers.TryDequeue(out var buffer))
|
||||
return buffer;
|
||||
else
|
||||
return new byte[size];
|
||||
}
|
||||
|
||||
public void Return(byte[] buffer)
|
||||
{
|
||||
buffers.Enqueue(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbiesObserve
|
||||
{
|
||||
public Guid GameId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbiesStopObserve
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyCreate
|
||||
{
|
||||
public Guid GameId { get; set; }
|
||||
[MaxLength(64)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int GameMode { get; set; }
|
||||
public int PlayerCount { get; set; }
|
||||
public int MaxPlayerCount { get; set; }
|
||||
[MaxLength(26)]
|
||||
public byte[]? PasswordHash { get; set; }
|
||||
[MaxLength(32)]
|
||||
public string? HostIp { get; set; }
|
||||
public int HostPort { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyDelete
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid GameId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyHostInfo
|
||||
{
|
||||
public Guid LobbyId { get; set; }
|
||||
[MaxLength(32)]
|
||||
public string? HostIp { get; set; }
|
||||
public int HostPort { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyInfo
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public int GameMode { get; set; }
|
||||
public int PlayerCount { get; set; }
|
||||
public int MaxPlayerCount { get; set; }
|
||||
public bool PasswordProtected { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyNatPunchDone
|
||||
{
|
||||
public Guid LobbyId { get; set; }
|
||||
public int NatPunchId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyRequestHostInfo
|
||||
{
|
||||
public Guid LobbyId { get; set; }
|
||||
[MaxLength(26)]
|
||||
public byte[]? PasswordHash { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyRequestNatPunch
|
||||
{
|
||||
public Guid LobbyId { get; set; }
|
||||
[MaxLength(26)]
|
||||
public byte[]? PasswordHash { get; set; }
|
||||
|
||||
public string? ClientIp { get; set; }
|
||||
public int ClientPort { get; set; }
|
||||
|
||||
public int NatPunchId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LobbyServerSourceGenerator\LobbyServerSourceGenerator.csproj" OutputItemType="Analyzer" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyUpdate
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public int GameMode { get; set; }
|
||||
public int PlayerCount { get; set; }
|
||||
public int MaxPlayerCount { get; set; }
|
||||
public byte[]? PasswordHash { get; set; }
|
||||
[MaxLength(32)]
|
||||
public string? HostIp { get; set; }
|
||||
public int HostPort { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
[LobbyMessage]
|
||||
public partial class LobbyWrongPassword
|
||||
{
|
||||
public Guid LobbyId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
public class NatPuncher
|
||||
{
|
||||
public static void NatPunch(IPEndPoint localEndpoint, IPEndPoint remoteEndpoint)
|
||||
{
|
||||
try
|
||||
{
|
||||
using Socket socket = new Socket(SocketType.Dgram, ProtocolType.Udp);
|
||||
socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.ReuseAddress, true);
|
||||
socket.ExclusiveAddressUse = false;
|
||||
socket.Bind(localEndpoint);
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
socket.SendTo(new byte[] { }, remoteEndpoint);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
namespace LobbyServerDto
|
||||
{
|
||||
public static class GameGuids
|
||||
{
|
||||
public static Guid NFS = new Guid("0572706f-0fd9-46a9-8ea6-5a31a5363442");
|
||||
public static HashSet<Guid> ValidGuids = new HashSet<Guid>() { NFS };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user