public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return(document);
            }
            var reader = response.Reader;

            var sessionId = reader.ReadInt32EndianAware();

            document.SetField("SessionId", sessionId);

            if (response.Connection.ProtocolVersion > 26)
            {
                var size  = reader.ReadInt32EndianAware();
                var token = reader.ReadBytesRequired(size);
                var t     = OToken.Parse(token);
                document.SetField("Token", token);
            }

            return(document);
        }
        public override ODocument Response(Response response)
        {
            ODocument document = new ODocument();

            if (response == null)
            {
                return(document);
            }

            var reader = response.Reader;

            var sessionId = reader.ReadInt32EndianAware();

            document.SetField("SessionId", sessionId);

            if (response.Connection.ProtocolVersion > 26)
            {
                var size  = reader.ReadInt32EndianAware();
                var token = reader.ReadBytesRequired(size);
                var t     = OToken.Parse(token);
                document.SetField("Token", token);
            }

            int clusterCount = -1;

            if (OClient.ProtocolVersion >= 7)
            {
                clusterCount = (int)reader.ReadInt16EndianAware();
            }
            else
            {
                clusterCount = reader.ReadInt32EndianAware();
            }

            document.SetField("ClusterCount", clusterCount);

            if (clusterCount > 0)
            {
                List <OCluster> clusters = new List <OCluster>();

                for (int i = 1; i <= clusterCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = reader.ReadInt32EndianAware();

                    cluster.Name = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(clusterNameLength));

                    cluster.Id = reader.ReadInt16EndianAware();

                    if (OClient.ProtocolVersion < 24)
                    {
                        int clusterTypeLength = reader.ReadInt32EndianAware();

                        string clusterType = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(clusterTypeLength));
                        //cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterType, true);
                    }
                    clusters.Add(cluster);
                }

                document.SetField("Clusters", clusters);
            }

            int clusterConfigLength = reader.ReadInt32EndianAware();

            byte[] clusterConfig = null;

            if (clusterConfigLength > 0)
            {
                clusterConfig = reader.ReadBytes(clusterConfigLength);
            }

            document.SetField("ClusterConfig", clusterConfig);

            string release = reader.ReadInt32PrefixedString();

            document.SetField("OrientdbRelease", release);

            return(document);
        }