public RabbitMQInvocation ReadInvocation(ReadOnlyMemory <byte> data) { // See WriteInvocation for the format ValidateArraySize(ref data, 2, "Invocation"); // Read excluded Ids IReadOnlyList <string> excludedConnectionIds = null; var idCount = MessagePackUtil.ReadArrayHeader(ref data); if (idCount > 0) { var ids = new string[idCount]; for (var i = 0; i < idCount; i++) { ids[i] = MessagePackUtil.ReadString(ref data); } excludedConnectionIds = ids; } // Read payload var message = ReadSerializedHubMessage(ref data); return(new RabbitMQInvocation(message, excludedConnectionIds)); }
private static void ValidateArraySize(ref ReadOnlyMemory <byte> data, int expectedLength, string messageType) { var length = MessagePackUtil.ReadArrayHeader(ref data); if (length < expectedLength) { throw new InvalidDataException($"Insufficient items in {messageType} array."); } }
public IReadOnlyList <string> ReadList(ReadOnlyMemory <byte> data) { IReadOnlyList <string> list = null; var itemCount = MessagePackUtil.ReadArrayHeader(ref data); if (itemCount > 0) { var items = new string[itemCount]; for (var i = 0; i < itemCount; i++) { items[i] = MessagePackUtil.ReadString(ref data); } list = items; } return(list); }