mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:36:30 +00:00
739759628a
add DONE during inference, correct handling on C# side
17 lines
561 B
C#
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);
|
|
}
|
|
} |