Files
annotations/Azaion.CommonSecurity/ZeroMQExtensions.cs
T
Alex Bezdieniezhnykh 739759628a fixed inference bugs
add DONE during inference, correct handling on C# side
2025-02-01 02:09:11 +02:00

17 lines
561 B
C#

using MessagePack;
using NetMQ;
using NetMQ.Sockets;
namespace Azaion.CommonSecurity;
public static class ZeroMqExtensions
{
public static T? Get<T>(this DealerSocket dealer, Func<byte[], bool>? shouldInterceptFn = null) where T : class
{
if (!dealer.TryReceiveFrameBytes(TimeSpan.FromMinutes(2), out var bytes))
throw new Exception($"Unable to get {typeof(T).Name}");
if (shouldInterceptFn != null && shouldInterceptFn(bytes))
return null;
return MessagePackSerializer.Deserialize<T>(bytes);
}
}