コード例 #1
0
        public static DqliteNodeInfo[] ParseNodesResponse(ResponseTypes type, int size, Memory <byte> data)
        {
            ThrowOnFailure(type, size, data);
            if (type != ResponseTypes.ResponseNodes)
            {
                throw new InvalidOperationException($"Invalid response: expected {ResponseTypes.ResponseNodes}, actually {type}");
            }

            var span = data.Span;

            var count = span.ReadUInt64();
            var nodes = new DqliteNodeInfo[count];

            for (var i = 0UL; i < count; ++i)
            {
                nodes[i]         = new DqliteNodeInfo();
                nodes[i].Id      = span.ReadUInt64();
                nodes[i].Address = span.ReadString();
                if (span.Length > 0)
                {
                    nodes[i].Role = (DqliteNodeRoles)span.ReadUInt64();
                }
            }

            return(nodes);
        }
コード例 #2
0
        public static DqliteNodeInfo ParseNodeResponse(ResponseTypes type, int size, Memory <byte> data)
        {
            ThrowOnFailure(type, size, data);
            if (type != ResponseTypes.ResponseNode)
            {
                throw new InvalidOperationException($"Invalid response: expected {ResponseTypes.ResponseNode}, actually {type}");
            }
            else if (data.Length == 0)
            {
                return(null);
            }

            var span = data.Span;

            var node = new DqliteNodeInfo();

            node.Id      = span.ReadUInt64();
            node.Address = span.ReadString();

            return(node);
        }