func (msg *ProtocolDataInputStream) Mark(readlimit int) {
	msg.mark = readlimit
}
Mark marks the current position
package impl
import (
	"bytes"
	"encoding/binary"
	"encoding/gob"
	"fmt"
	"io"
	"math"
	"reflect"
	"tgdb"
	"strings"
	"sync"
	"sync/atomic"
	"time"
)
const (
	AbstractMessage int = -100
)
const (
	VerbPingMessage int = 0
	VerbHandShakeRequest  int = 1
	VerbHandShakeResponse int = 2
	VerbAuthenticateRequest  int = 3
	VerbAuthenticateResponse int = 4
	VerbBeginTransactionRequest     int = 5
	VerbBeginTransactionResponse    int = 6
	VerbCommitTransactionRequest    int = 7
	VerbCommitTransactionResponse   int = 8
	VerbRollbackTransactionRequest  int = 9
	VerbRollbackTransactionResponse int = 10
	VerbQueryRequest  int = 11
	VerbQueryResponse int = 12
	VerbTraverseRequest  int = 13
	VerbTraverseResponse int = 14
	VerbAdminRequest  int = 15
	VerbAdminResponse int = 16
	VerbMetadataRequest  int = 19
	VerbMetadataResponse int = 20
	VerbGetEntityRequest  int = 21
	VerbGetEntityResponse int = 22
	VerbGetLargeObjectRequest  int = 23
	VerbGetLargeObjectResponse int = 24
	VerbBeginExportRequest    int = 25
	VerbBeginExportResponse   int = 26
	VerbPartialExportRequest  int = 27
	VerbPartialExportResponse int = 28
	VerbCancelExportRequest   int = 29
	VerbBeginImportRequest    int = 31
	BeginImportResponse       int = 32
	VerbPartialImportRequest  int = 33
	VerbPartialImportResponse int = 34
	VerbDumpStacktraceRequest int = 39
	VerbDisconnectChannelRequest    int = 40
	VerbSessionForcefullyTerminated int = 41
	VerbDecryptBufferRequest  int = 44
	VerbDecryptBufferResponse int = 45
	VerbExceptionMessage int = 100
	VerbInvalidMessage   int = -1
)
type CommandVerbs struct {
	id          int
	name        string
	implementor string
}
var PreDefinedVerbs = map[int]CommandVerbs{
	VerbPingMessage:                 {id: VerbPingMessage, name: "VerbPingMessage", implementor: "pdu.VerbPingMessage"},
	VerbHandShakeRequest:            {id: VerbHandShakeRequest, name: "VerbHandShakeRequest", implementor: "pdu.HandshakeRequest"},
	VerbHandShakeResponse:           {id: VerbHandShakeResponse, name: "VerbHandShakeResponse", implementor: "pdu.HandshakeResponse"},
	VerbAuthenticateRequest:         {id: VerbAuthenticateRequest, name: "VerbAuthenticateRequest", implementor: "pdu.VerbAuthenticateRequest"},
	VerbAuthenticateResponse:        {id: VerbAuthenticateResponse, name: "VerbAuthenticateResponse", implementor: "pdu.VerbAuthenticateResponse"},
	VerbBeginTransactionRequest:     {id: VerbBeginTransactionRequest, name: "VerbBeginTransactionRequest", implementor: "pdu.VerbBeginTransactionRequest"},
	VerbBeginTransactionResponse:    {id: VerbBeginTransactionResponse, name: "VerbBeginTransactionResponse", implementor: "pdu.VerbBeginTransactionResponse"},
	VerbCommitTransactionRequest:    {id: VerbCommitTransactionRequest, name: "VerbCommitTransactionRequest", implementor: "pdu.VerbCommitTransactionRequest"},
	VerbCommitTransactionResponse:   {id: VerbCommitTransactionResponse, name: "VerbCommitTransactionResponse", implementor: "pdu.VerbCommitTransactionResponse"},
	VerbRollbackTransactionRequest:  {id: VerbRollbackTransactionRequest, name: "VerbRollbackTransactionRequest", implementor: "pdu.VerbRollbackTransactionRequest"},
	VerbRollbackTransactionResponse: {id: VerbRollbackTransactionResponse, name: "VerbRollbackTransactionResponse", implementor: "pdu.VerbRollbackTransactionResponse"},
	VerbQueryRequest:                {id: VerbQueryRequest, name: "VerbQueryRequest", implementor: "pdu.VerbQueryRequest"},
	VerbQueryResponse:               {id: VerbQueryResponse, name: "VerbQueryResponse", implementor: "pdu.VerbQueryResponse"},
	VerbTraverseRequest:             {id: VerbTraverseRequest, name: "VerbTraverseRequest", implementor: "pdu.VerbTraverseRequest"},
	VerbTraverseResponse:            {id: VerbTraverseResponse, name: "VerbTraverseResponse", implementor: "pdu.VerbTraverseResponse"},
	VerbAdminRequest:                {id: VerbAdminRequest, name: "VerbAdminRequest", implementor: "admin.VerbAdminRequest"},
	VerbAdminResponse:               {id: VerbAdminResponse, name: "VerbAdminResponse", implementor: "admin.VerbAdminResponse"},
	VerbMetadataRequest:             {id: VerbMetadataRequest, name: "VerbMetadataRequest", implementor: "pdu.VerbMetadataRequest"},
	VerbMetadataResponse:            {id: VerbMetadataResponse, name: "VerbMetadataResponse", implementor: "pdu.VerbMetadataResponse"},
	VerbGetEntityRequest:            {id: VerbGetEntityRequest, name: "VerbGetEntityRequest", implementor: "pdu.VerbGetEntityRequest"},     
	VerbGetEntityResponse:           {id: VerbGetEntityResponse, name: "VerbGetEntityResponse", implementor: "pdu.VerbGetEntityResponse"},  
	VerbGetLargeObjectRequest:       {id: VerbGetLargeObjectRequest, name: "VerbGetLargeObjectRequest", implementor: "pdu.VerbGetLargeObjectRequest"},
	VerbGetLargeObjectResponse:      {id: VerbGetLargeObjectResponse, name: "VerbGetLargeObjectResponse", implementor: "pdu.VerbGetLargeObjectResponse"},
	VerbDumpStacktraceRequest:       {id: VerbDumpStacktraceRequest, name: "VerbDumpStacktraceRequest", implementor: "pdu.VerbDumpStacktraceRequest"},
	VerbDisconnectChannelRequest:    {id: VerbDisconnectChannelRequest, name: "VerbDisconnectChannelRequest", implementor: "pdu.VerbDisconnectChannelRequest"},
	VerbSessionForcefullyTerminated: {id: VerbSessionForcefullyTerminated, name: "VerbSessionForcefullyTerminated", implementor: "pdu.VerbSessionForcefullyTerminated"},
	VerbDecryptBufferRequest:        {id: VerbDecryptBufferRequest, name: "VerbDecryptBufferRequest", implementor: "pdu.VerbDecryptBufferRequest"},
	VerbDecryptBufferResponse:       {id: VerbDecryptBufferResponse, name: "VerbDecryptBufferResponse", implementor: "pdu.VerbDecryptBufferResponse"},
	VerbExceptionMessage:            {id: VerbExceptionMessage, name: "VerbExceptionMessage", implementor: "pdu.VerbExceptionMessage"},
	VerbInvalidMessage:              {id: VerbInvalidMessage, name: "VerbInvalidMessage", implementor: "pdu.VerbInvalidMessage"},
}
func NewVerbId(id int, name, impl string) *CommandVerbs {
	newConfig := &CommandVerbs{id: id, name: name, implementor: impl}
	return newConfig
}
func GetVerb(id int) *CommandVerbs {
	verb, ok := PreDefinedVerbs[id]
	if ok {
		return &verb
	} else {
		invalid := PreDefinedVerbs[VerbInvalidMessage]
		return &invalid
	}
}
func (obj *CommandVerbs) GetID() int {
	return obj.id
}
func (obj *CommandVerbs) GetName() string {
	return obj.name
}
func (obj *CommandVerbs) GetImplementor() string {
	return obj.implementor
}
type ProtocolDataInputStream struct {
	mark                int	 
	Buf                 []byte
	BufLen              int
	iStreamCurPos       int
	iStreamEncoding     string
	iStreamReferenceMap map[int64]tgdb.TGEntity
}
func (msg *ProtocolDataInputStream) ReadBoolean() (bool, tgdb.TGError) {
	if msg.iStreamCurPos >= msg.BufLen {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadBoolean('%+v') as msg.CurPos >= msg.BufLen", false))
		errMsg := fmt.Sprint("End of data stream")
		return false, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := msg.Buf[msg.iStreamCurPos]
	msg.iStreamCurPos += 1
	if a == 0x00 {
		if logger.IsDebug() {
			logger.Debug(fmt.Sprintf("Returning ProtocolDataInputStream::ReadBoolean('%+v') as a == 0x00", false))
		}
		return false, nil
	}
	return true, nil
}
func (msg *ProtocolDataInputStream) ReadByte() (byte, tgdb.TGError) {
	if msg.iStreamCurPos >= msg.BufLen {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadByte('%+v') as msg.CurPos >= msg.BufLen", 0))
		errMsg := fmt.Sprint("End of data stream")
		return 0, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := msg.Buf[msg.iStreamCurPos]
	msg.iStreamCurPos += 1
	return a, nil
}
func (msg *ProtocolDataInputStream) ReadChar() (string, tgdb.TGError) {
	if (msg.iStreamCurPos + 2) > msg.BufLen {
		logger.Error(fmt.Sprintf("Returning ProtocolDataInputStream::ReadChar('%+v') as msg.CurPos+2 > msg.BufLen", ""))
		errMsg := fmt.Sprint("End of data stream")
		return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := int(msg.Buf[msg.iStreamCurPos]) << 8
	b := int(msg.Buf[msg.iStreamCurPos+1]) & 0xff
	msg.iStreamCurPos += 2
	c := fmt.Sprintf("%c", a+b)
	return c, nil
}
func (msg *ProtocolDataInputStream) ReadDouble() (float64, tgdb.TGError) {
	a, err := msg.ReadLong()
	if err != nil {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadDouble('%+v') as msg.ReadInt resulted in error", 0))
		return 0, err
	}
	return math.Float64frombits(uint64(a)), nil
}
func (msg *ProtocolDataInputStream) ReadFloat() (float32, tgdb.TGError) {
	a, err := msg.ReadInt()
	if err != nil {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadFloat('%+v') as msg.ReadInt resulted in error", 0))
		return 0, err
	}
	return math.Float32frombits(uint32(a)), nil
}
func (msg *ProtocolDataInputStream) ReadFully(b []byte) ([]byte, tgdb.TGError) {
	if b == nil {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadFully as input byte array is EMPTY"))
		errMsg := fmt.Sprint("Input argument to ReadFully is null")
		return nil, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	return msg.ReadFullyAtPos(b, msg.iStreamCurPos, len(b))
}
func (msg *ProtocolDataInputStream) ReadFullyAtPos(b []byte, readCurPos, readLen int) ([]byte, tgdb.TGError) {
	if readLen <= 0 {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadFullyAtPos('%+v') as readLen <= 0", readCurPos))
		errMsg := fmt.Sprint("Input argument representing how many bytes to read in ReadFullyAtPos is null")
		return nil, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	if (msg.iStreamCurPos + readLen) > msg.BufLen {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadFullyAtPos as (msg.CurPos + readLen) > msg.BufLen"))
		errMsg := fmt.Sprint("Input readLen to ReadFully is invalid")
		return nil, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	copy(b, msg.Buf[msg.iStreamCurPos:(msg.iStreamCurPos +readLen)])
	msg.iStreamCurPos = msg.iStreamCurPos + readLen
	return b, nil
}
func (msg *ProtocolDataInputStream) ReadInt() (int, tgdb.TGError) {
	if (msg.iStreamCurPos + 4) > msg.BufLen {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadInt as (msg.CurPos + 4) > msg.BufLen"))
		errMsg := fmt.Sprint("End of data stream")
		return -1, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := int(msg.Buf[msg.iStreamCurPos]) << 24
	b := int(msg.Buf[msg.iStreamCurPos+1]) << 16 & 0x00ff0000
	c := int(msg.Buf[msg.iStreamCurPos+2]) << 8 & 0x0000ff00
	d := int(msg.Buf[msg.iStreamCurPos+3]) & 0xff
	msg.iStreamCurPos += 4
	return a + b + c + d, nil
}
func (msg *ProtocolDataInputStream) ReadLine() (string, tgdb.TGError) {
	return "", nil
}
func (msg *ProtocolDataInputStream) ReadLong() (int64, tgdb.TGError) {
	if (msg.iStreamCurPos + 8) > msg.BufLen {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadLong as (msg.CurPos + 8) > msg.BufLen"))
		errMsg := fmt.Sprint("End of data stream")
		return -1, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a, err := msg.ReadInt()
	if err != nil {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadLong('%d') as msg.ReadInt resulted in error", 0))
		return 0, err
	}
	b, err := msg.ReadInt()
	if err != nil {
		logger.Error(fmt.Sprintf("ERROR: Returning ProtocolDataInputStream::ReadLong('%d') as msg.ReadInt resulted in error", 0))
		return 0, err
	}
	c := int64((a << 32) + (b & 0xffffffff))
	return c, nil
}
func (msg *ProtocolDataInputStream) ReadShort() (int16, tgdb.TGError) {
	if (msg.iStreamCurPos + 2) > msg.BufLen {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadShort as (msg.CurPos + 2) > msg.BufLen"))
		errMsg := fmt.Sprint("End of data stream")
		return -1, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := int16(msg.Buf[msg.iStreamCurPos]) << 8
	b := int16(msg.Buf[msg.iStreamCurPos+1]) & 0xff
	msg.iStreamCurPos += 2
	c := a + b
	return c, nil
}
func (msg *ProtocolDataInputStream) ReadUnsignedByte() (int, tgdb.TGError) {
	if msg.iStreamCurPos >= msg.BufLen {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUnsignedByte as msg.CurPos > msg.BufLen"))
		errMsg := fmt.Sprint("End of data stream")
		return -1, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := int(msg.Buf[msg.iStreamCurPos]) & 0xff
	msg.iStreamCurPos += 1
	return a, nil
}
func (msg *ProtocolDataInputStream) ReadUnsignedShort() (uint16, tgdb.TGError) {
	if (msg.iStreamCurPos + 2) > msg.BufLen {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUnsignedShort as (msg.CurPos + 2) > msg.BufLen"))
		errMsg := fmt.Sprint("End of data stream")
		return 0, GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	a := int(msg.Buf[msg.iStreamCurPos]) << 8
	b := int(msg.Buf[msg.iStreamCurPos+1]) & 0xff
	msg.iStreamCurPos += 2
	c := uint16((a + b) & 0x0000ffff)
	return c, nil
}
func (msg *ProtocolDataInputStream) ReadUTF() (string, tgdb.TGError) {
	start := msg.iStreamCurPos
	utfLen, err := msg.ReadUnsignedShort()
	if err != nil {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTF as msg.ReadUnsignedShort resulted in error"))
		msg.iStreamCurPos = start
		return "", err
	}
	if logger.IsDebug() {
		logger.Debug(fmt.Sprintf("Inside ProtocolDataInputStream::ReadUTF() utfLength to read: '%d'", utfLen))
	}
	str, err := msg.ReadUTFString(int(utfLen))
	if logger.IsDebug() {
		logger.Debug(fmt.Sprintf("Returning ProtocolDataInputStream::ReadUTF from the contents w/ ('%s') & error ('%+v')", str, err))
	}
	return str, err
}
func (msg *ProtocolDataInputStream) ReadUTFString(utfLen int) (string, tgdb.TGError) {
	if (msg.iStreamCurPos + utfLen) > msg.BufLen {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString as (msg.CurPos + utfLen) > msg.BufLen"))
		errMsg := fmt.Sprint("End of data stream")
		return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	charBuf := ""
	start := msg.iStreamCurPos
	lastPos := msg.iStreamCurPos + utfLen
	strLen := 0
	var c, cVal, char2, char3 int
	for {
		if !(msg.iStreamCurPos < lastPos) {
			break
		}
		c = int(msg.Buf[msg.iStreamCurPos]) & 0xff
		msg.iStreamCurPos += 1
		cVal = c >> 4
		if cVal <= 7 {  
			charBuf = charBuf + string(c)
			strLen++
		} else if cVal == 12 || cVal == 13 {  
			if msg.iStreamCurPos+1 > lastPos {
				msg.iStreamCurPos = start
				logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString as msg.CurPos+1 > lastPos"))
				errMsg := fmt.Sprint("Data Format Issue")
				return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
			}
			char2 = int(msg.Buf[msg.iStreamCurPos])
			msg.iStreamCurPos += 1
			if (char2 & 0xC0) != 0x80 {
				msg.iStreamCurPos = start
				logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString as (char2 & 0xC0) != 0x80"))
				errMsg := fmt.Sprint("Data Format Issue")
				return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
			}
			c1 := ((c & 0x1F) << 6) | (char2 & 0x3F)
			charBuf = charBuf + string(c1)
			strLen++
		} else if cVal == 14 {  
			if msg.iStreamCurPos+2 > lastPos {
				msg.iStreamCurPos = start
				logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString as msg.CurPos+2 > lastPos"))
				errMsg := fmt.Sprint("Data Format Issue")
				return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
			}
			char2 = int(msg.Buf[msg.iStreamCurPos])
			msg.iStreamCurPos += 1
			char3 = int(msg.Buf[msg.iStreamCurPos])
			msg.iStreamCurPos += 1
			if ((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80) {
				msg.iStreamCurPos = start
				logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString as ((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80)"))
				errMsg := fmt.Sprint("Data Format Issue")
				return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
			}
			c1 := ((c & 0x0F) << 12) | ((char2 & 0x3F) << 6) | ((char3 & 0x3F) << 0)
			charBuf = charBuf + string(c1)
			strLen++
		} else {  
			msg.iStreamCurPos = start
			logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString for 10xxxxxx, 1111xxxx"))
			errMsg := fmt.Sprint("Data Format Issue")
			return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
		}
	}
	if msg.iStreamCurPos != lastPos {
		msg.iStreamCurPos = start
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::ReadUTFString as msg.CurPos != lastPos"))
		errMsg := fmt.Sprint("Data Format Issue")
		return "", GetErrorByType(TGErrorIOException, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	return charBuf, nil
}
func (msg *ProtocolDataInputStream) SkipBytes(n int) (int, tgdb.TGError) {
	if logger.IsDebug() {
		logger.Debug(fmt.Sprintf("Entering ProtocolDataInputStream::SkipBytes('%d'), contents are '%+v'", n, msg.Buf))
	}
	if n < 0 {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::SkipBytes as n < 0"))
		errMsg := fmt.Sprint("Invalid bytes to skip")
		return 0, GetErrorByType(TGErrorInvalidMessageLength, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	avail := msg.BufLen - msg.iStreamCurPos
	if logger.IsDebug() {
		logger.Debug(fmt.Sprintf("Inside ProtocolDataInputStream::SkipBytes - Available bytes ('%d') compared w/ To-Be-Skipped '%d'", avail, n))
	}
	if avail <= n {
		if logger.IsDebug() {
			logger.Debug(fmt.Sprintf("Returning ProtocolDataInputStream::SkipBytes as avail <= n from the contents w/ ('%d')", avail))
		}
		msg.iStreamCurPos = msg.BufLen
		return avail, nil
	}
	msg.iStreamCurPos = msg.iStreamCurPos + n
	if logger.IsDebug() {
		logger.Debug(fmt.Sprintf("Returning ProtocolDataInputStream::SkipBytes from the contents w/ ('%d')", n))
	}
	return n, nil
}
func (msg *ProtocolDataInputStream) String() string {
	var buffer bytes.Buffer
	buffer.WriteString("ProtocolDataInputStream:{")
	buffer.WriteString(fmt.Sprintf("Buffer Length: %d", msg.BufLen))
	buffer.WriteString(fmt.Sprintf(", Current Position: %d", msg.iStreamCurPos))
	buffer.WriteString(fmt.Sprintf(", Encoding: %s", msg.iStreamEncoding))
	buffer.WriteString(fmt.Sprintf(", Buffer: %s", bytes.NewBuffer(msg.Buf).String()))
	buffer.WriteString(fmt.Sprintf(", Reference Map: %+v", msg.iStreamReferenceMap))
	buffer.WriteString("}")
	return buffer.String()
}
func (msg *ProtocolDataInputStream) Available() (int, tgdb.TGError) {
	if (msg.BufLen-msg.iStreamCurPos) < 0 {
		logger.Error(fmt.Sprint("ERROR: Returning ProtocolDataInputStream::Available as (msg.BufLen-msg.CurPos) < 0"))
		errMsg := fmt.Sprint("Invalid data length of Protocol Data Input Stream")
		return 0, GetErrorByType(TGErrorInvalidMessageLength, INTERNAL_SERVER_ERROR, errMsg, "")
	}
	return msg.BufLen - msg.iStreamCurPos, nil
}
func (msg *ProtocolDataInputStream) GetPosition() int64 {
	return int64(msg.iStreamCurPos)
}
func (msg *ProtocolDataInputStream) GetReferenceMap() map[int64]tgdb.TGEntity {
	return msg.iStreamReferenceMap
}