baseline: OpenMU upstream b5a0961 (fresh source)

This commit is contained in:
Acentech Dev
2026-07-14 19:00:35 +03:00
parent 450402e47d
commit 36fc125d5c
11968 changed files with 748705 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
// <copyright file="ConnectionExtensions.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.Network;
/// <summary>
/// Extension methods for <see cref="IConnection"/>.
/// </summary>
public static class ConnectionExtensions
{
/// <summary>
/// Sends a message asynchronously.
/// </summary>
/// <param name="connection">The connection.</param>
/// <param name="packetBuilder">The packet builder which writes to the <see cref="IConnection.Output"/> and returns the length of the packet in bytes.</param>
public static async ValueTask SendAsync(this IConnection connection, Func<int> packetBuilder)
{
if (!connection.Connected)
{
return;
}
using var l = await connection.OutputLock.LockAsync().ConfigureAwait(false);
var length = packetBuilder();
connection.Output.Advance(length);
await connection.Output.FlushAsync().ConfigureAwait(false);
}
}