public IEnumerable <MessageData> Unchunk(int[]?allowedTopicIds = null)
        {
            using var inStream = new MemoryStream(Data !);
            var stream = new MemoryStream();

            if (Compression == CompressionType.Bz2)
            {
                BZip2.Decompress(inStream, stream, false);
            }
            else
            {
                stream = inStream;
            }

            stream.Position = 0;
            var res = new List <MessageData>(50);

            while (stream.Position < stream.Length)
            {
                var message = RecordsFactory.Read <MessageData>(stream, MessageData.OpCode);
                if (message != null &&
                    (allowedTopicIds == null || allowedTopicIds.Contains(message.ConnectionId)))
                {
                    res.Add(message);
                }
            }

            stream.Dispose();
            return(res);
        }
Beispiel #2
0
        private string GetTopicType()
        {
            var stream = new MemoryStream(Data !);

            while (stream.Position < stream.Length)
            {
                var(name, data) = RecordsFactory.ReadField(stream);
                if (name == "type")
                {
                    _type = Encoding.UTF8.GetString(data);
                    return(_type);
                }
            }

            throw new ParsingException($"Type not found for topic {Topic}");
        }