Skip to content

Commit

Permalink
grpc wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Xsear committed Jan 4, 2024
1 parent ea57e4a commit e6e5a89
Show file tree
Hide file tree
Showing 46 changed files with 1,904 additions and 959 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,7 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# VSCode Shared Configuration Files
.vscode/
3 changes: 2 additions & 1 deletion Lib/Shared.Web/BaseWebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static IHost Build(Type serverType, IConfiguration configuration)
}

Log.Information($"Starting web host {serverType.FullName}");
#pragma warning disable SYSLIB0039 // TLS 1.0 required
var hostBuilder =
Host.CreateDefaultBuilder()
.ConfigureWebHostDefaults(webBuilder =>
Expand Down Expand Up @@ -71,7 +72,7 @@ public static IHost Build(Type serverType, IConfiguration configuration)
});
})
.UseSerilog();

#pragma warning restore SYSLIB0039
return hostBuilder.Build();
}
catch (Exception ex)
Expand Down
2 changes: 1 addition & 1 deletion PIN.targets
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
<CodeAnalysisRuleSet>..\..\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
Expand Down
37 changes: 25 additions & 12 deletions UdpHosts/GameServer/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ public bool SendGSS<T>(T packet, ulong entityId, Enums.GSS.Controllers? controll
/// Send a GSS class to the client
/// </summary>
/// <typeparam name="TPacket">The type of the packet</typeparam>
/// <param name="packet"></param>
/// <param name="entityId"></param>
/// <param name="packet">The packet</param>
/// <param name="entityId">Id of the entity the packet is for</param>
/// <param name="controllerIdParameter">If not provided on the <see cref="GSSMessageAttribute" /> on the packet, the controller Id may be specified here</param>
/// <param name="messageEnumType">Optionally, the enum type containing the message id may be specified for enhanced verbose-level logging</param>
/// <returns>true if the operation succeeded, false in all other cases</returns>
Expand Down Expand Up @@ -347,12 +347,12 @@ public bool SendGSSClass<TPacket>(TPacket packet, ulong entityId, Enums.GSS.Cont
/// Send an <see cref="IAero" /> package to the client
/// </summary>
/// <typeparam name="TPacket">The type of the packet</typeparam>
/// <param name="packet"></param>
/// <param name="entityId"></param>
/// <param name="packet">The Aero message</param>
/// <param name="entityId">Id of the entity the packet is for</param>
/// <param name="messageIdOverride">Optional way to override the message ID</param>
/// <param name="messageEnumType">Optionally, the enum type containing the message id may be specified for enhanced verbose-level logging</param>
/// <returns>true if the operation succeeded, false in all other cases</returns>
/// <exception cref="ArgumentException"></exception>
/// <exception cref="ArgumentException">The passed packet does not have the AeroMessageIdAttribute</exception>
public bool SendIAero<TPacket>(TPacket packet, ulong entityId = 0, byte messageIdOverride = 0, Type? messageEnumType = null)
where TPacket : class, IAero
{
Expand Down Expand Up @@ -419,13 +419,26 @@ public bool SendIAeroChanges<TPacket>(TPacket packet, ulong entityId)
return SendPacketMemory(entityId, 1, typeCode, ref packetMemory);
}

public bool SendIAeroChanges<TPacket>(TPacket packet, ulong entityId, Memory<byte> packetMemory)
where TPacket : class, IAeroViewInterface
{
if (typeof(TPacket).GetCustomAttributes(typeof(AeroMessageIdAttribute), false).FirstOrDefault() is not AeroMessageIdAttribute aeroMsgAttr)
{
throw new ArgumentException($"The passed package is required to be annotated with {nameof(AeroMessageIdAttribute)} (Type: {typeof(TPacket).FullName})");
}

var typeCode = (Enums.GSS.Controllers)aeroMsgAttr.ControllerId;

return SendPacketMemory(entityId, 1, typeCode, ref packetMemory);
}

/// <summary>
/// Send serialized data of a gss channel packet to the client
/// </summary>
/// <param name="entityId"></param>
/// <param name="messageId"></param>
/// <param name="controllerId"></param>
/// <param name="packetToSend"></param>
/// <param name="entityId">Id of the entity the packet is for</param>
/// <param name="messageId">Message Id relative to the controllerId</param>
/// <param name="controllerId">Typecode of the entity matching the view or controller</param>
/// <param name="packetToSend">Memory buffer</param>
/// <param name="msgEnumType">Optionally, the enum type containing the message id may be specified for enhanced verbose-level logging</param>
/// <returns>true if the operation succeeded, false in all other cases</returns>
/// <exception cref="InvalidOperationException">If <see cref="msgEnumType" /> is not null and does not contain an element with a value equal to <see cref="messageId" /> </exception>
Expand Down Expand Up @@ -472,8 +485,8 @@ private bool SendPacketMemory(ulong entityId,
/// <summary>
/// Send serialized data of a matrix channel packet to the client
/// </summary>
/// <param name="messageId"></param>
/// <param name="packetMemory"></param>
/// <param name="messageId">Id of the matrix message being sent</param>
/// <param name="packetMemory">Memory buffer</param>
/// <param name="msgEnumType">TODO: Optionally, the enum type containing the message id may be specified for enhanced verbose-level logging</param>
/// <returns>true if the operation succeeded, false in all other cases</returns>
private bool SendPacketMemoryMatrix(byte messageId, ref Memory<byte> packetMemory, Type? msgEnumType = null)
Expand All @@ -488,7 +501,7 @@ private bool SendPacketMemoryMatrix(byte messageId, ref Memory<byte> packetMemor
/// <summary>
/// Send data to the client
/// </summary>
/// <param name="packetData"></param>
/// <param name="packetData">Memory buffer</param>
/// <returns>true if the operation succeeded, false in all other cases</returns>
private bool Send(Memory<byte> packetData)
{
Expand Down
1 change: 1 addition & 0 deletions UdpHosts/GameServer/ChannelType.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#nullable enable
namespace GameServer;

[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1602:EnumerationItemsMustBeDocumented", Justification = "See the wiki for more details on how the channels differ: https://github.com/themeldingwars/Documentation/wiki/Game-Server-Protocol-Overview#main-connection")]
public enum ChannelType : byte
{
Control = 0,
Expand Down
Loading

0 comments on commit e6e5a89

Please sign in to comment.