using MessagePack; using NetMQ; using NetMQ.Sockets; namespace Azaion.CommonSecurity; public static class ZeroMqExtensions { public static T? Get(this DealerSocket dealer, Func? 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(bytes); } }