public ResponseDecoder(TsTtbResp response)
        {
            using (var s = new OtpInputStream(response.Response))
            {
                byte tag = s.Read1();
                if (tag != OtpExternal.VersionTag)
                {
                    string msg = string.Format(
                        "Expected OTP input stream to start with {0}, got {1}",
                        OtpExternal.VersionTag,
                        tag);
                    throw new InvalidOperationException(msg);
                }

                tag = s.Peek();
                switch (tag)
                {
                case OtpExternal.AtomTag:
                    string atom = s.ReadAtom();
                    decodedResponse = ParseAtomResult(atom);
                    break;

                case OtpExternal.SmallTupleTag:
                case OtpExternal.LargeTupleTag:
                    decodedResponse = ParseTupleResult(s);
                    break;

                default:
                    throw new InvalidOperationException("Expected an atom or tuple.");
                }
            }
        }
        public ResponseDecoder(TsTtbResp response)
        {
            using (var s = new OtpInputStream(response.Response))
            {
                byte tag = s.Read1();
                if (tag != OtpExternal.VersionTag)
                {
                    string msg = string.Format(
                        "Expected OTP input stream to start with {0}, got {1}",
                        OtpExternal.VersionTag,
                        tag);
                    throw new InvalidOperationException(msg);
                }

                tag = s.Peek();
                switch (tag)
                {
                    case OtpExternal.AtomTag:
                        string atom = s.ReadAtom();
                        decodedResponse = ParseAtomResult(atom);
                        break;
                    case OtpExternal.SmallTupleTag:
                    case OtpExternal.LargeTupleTag:
                        decodedResponse = ParseTupleResult(s);
                        break;
                    default:
                        throw new InvalidOperationException("Expected an atom or tuple.");
                }
            }
        }