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); }
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()); } }
/// <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(); } }
public static bool Equals(INngMsg lhs, INngMsg rhs) { return(BytesEqual(lhs.AsSpan(), rhs.AsSpan()) && BytesEqual(lhs.Header.AsSpan(), rhs.Header.AsSpan())); }