Exemple #1
0
        public NngResult <Unit> SendMsg(INngMsg message, Defines.NngFlag flags = default)
        {
            var res = Unit.OkIfZero(nng_sendmsg(NativeNngStruct, message.NativeNngStruct, flags));

            if (res.IsOk())
            {
                // If call succeeds, nng takes ownership of message.
                var _ = message.Take();
            }
            return(res);
        }
Exemple #2
0
        public MsgBuilder(INngMsg message)
        {
            var headerSpan = message.Header.AsSpan();

            if (headerSpan.Length > 0)
            {
                Header = new MsgPart(headerSpan.ToArray());
            }
            var bodySpan = message.AsSpan();

            if (bodySpan.Length > 0)
            {
                Body = new MsgPart(bodySpan.ToArray());
            }
        }
Exemple #3
0
        /// <summary>
        /// Copy contents of nng message from unmanaged to managed memory.
        /// </summary>
        /// <param name="message"></param>
        public Msg(INngMsg message)
        {
            var headerSpan = message.Header.AsSpan();

            if (headerSpan.Length > 0)
            {
                header = headerSpan.ToArray();
            }
            var bodySpan = message.AsSpan();

            if (bodySpan.Length > 0)
            {
                body = bodySpan.ToArray();
            }
        }
Exemple #4
0
 public static bool Equals(INngMsg lhs, INngMsg rhs)
 {
     return(BytesEqual(lhs.AsSpan(), rhs.AsSpan()) && BytesEqual(lhs.Header.AsSpan(), rhs.Header.AsSpan()));
 }