Example #1
0
        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.");
            }
        }
Example #2
0
        private static IReadOnlyList <string> ReadList(ref ReadOnlyMemory <byte> data)
        {
            // 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;
            }

            return(excludedConnectionIds);
        }