2026-04-18 06:04:39 +01:00
|
|
|
using LiteNetLib;
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
|
|
|
|
namespace GameCult.Networking
|
|
|
|
|
{
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Adds MessagePack-based send helpers for <see cref="NetPeer"/>.
|
|
|
|
|
/// </summary>
|
2026-04-18 06:04:39 +01:00
|
|
|
public static class NetPeerExtensions
|
|
|
|
|
{
|
2026-04-18 13:01:24 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// Serializes and sends a message using reliable ordered delivery.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">The concrete message type.</typeparam>
|
|
|
|
|
/// <param name="peer">The peer to send through.</param>
|
|
|
|
|
/// <param name="message">The message to serialize and send.</param>
|
2026-04-18 06:04:39 +01:00
|
|
|
public static void Send<T>(this NetPeer peer, T message) where T : Message
|
|
|
|
|
{
|
2026-04-18 13:01:24 +01:00
|
|
|
peer.Send(MessageSerialization.Serialize(message), DeliveryMethod.ReliableOrdered);
|
2026-04-18 06:04:39 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-18 13:01:24 +01:00
|
|
|
}
|