Beispiel #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.");
            }
        }
Beispiel #2
0
        public MsmqGroupCommand ReadGroupCommand(ReadOnlyMemory <byte> data)
        {
            // See WriteGroupCommand for format.
            ValidateArraySize(ref data, 5, "GroupCommand");

            var id           = MessagePackUtil.ReadInt32(ref data);
            var serverName   = MessagePackUtil.ReadString(ref data);
            var action       = (GroupAction)MessagePackUtil.ReadByte(ref data);
            var groupName    = MessagePackUtil.ReadString(ref data);
            var connectionId = MessagePackUtil.ReadString(ref data);

            return(new MsmqGroupCommand(id, serverName, action, groupName, connectionId));
        }
Beispiel #3
0
        public static SerializedHubMessage ReadSerializedHubMessage(ref ReadOnlyMemory <byte> data)
        {
            var count          = MessagePackUtil.ReadMapHeader(ref data);
            var serializations = new SerializedMessage[count];

            for (var i = 0; i < count; i++)
            {
                var protocol   = MessagePackUtil.ReadString(ref data);
                var serialized = MessagePackUtil.ReadBytes(ref data);
                serializations[i] = new SerializedMessage(protocol, serialized);
            }

            return(new SerializedHubMessage(serializations));
        }
Beispiel #4
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);
        }
Beispiel #5
0
 public int ReadAck(ReadOnlyMemory <byte> data)
 {
     // See WriteAck for format
     ValidateArraySize(ref data, 1, "Ack");
     return(MessagePackUtil.ReadInt32(ref data));
 }