bug fix
This commit is contained in:
		
							parent
							
								
									904f787e64
								
							
						
					
					
						commit
						b7e43ac8fe
					
				
							
								
								
									
										4
									
								
								coder.go
								
								
								
								
							
							
						
						
									
										4
									
								
								coder.go
								
								
								
								
							| 
						 | 
					@ -35,8 +35,8 @@ type Packet interface {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// BytesV 返回流字节
 | 
						// BytesV 返回流字节
 | 
				
			||||||
	BytesV() []byte
 | 
						BytesV() []byte
 | 
				
			||||||
	// UTF8StringV 返回流的utf8字符串值
 | 
						// Utf8StringV 返回流的utf8字符串值
 | 
				
			||||||
	UTF8StringV() string
 | 
						Utf8StringV() string
 | 
				
			||||||
	// Int32V 返回流的int32值
 | 
						// Int32V 返回流的int32值
 | 
				
			||||||
	Int32V() (val int32, err error)
 | 
						Int32V() (val int32, err error)
 | 
				
			||||||
	// UInt32V 返回流的uint32值
 | 
						// UInt32V 返回流的uint32值
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,8 +21,8 @@ func NewDecoder(reader io.Reader) *Decoder {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SeqID return the SequenceID of the decoding packet
 | 
					// SeqId return the SequenceID of the decoding packet
 | 
				
			||||||
func (d *Decoder) SeqID() int {
 | 
					func (d *Decoder) SeqId() int {
 | 
				
			||||||
	return d.tag.Sid()
 | 
						return d.tag.Sid()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ func (d *Decoder) GetFullFilledPacket() (packet Packet, err error) {
 | 
				
			||||||
	packet = &StreamPacket{
 | 
						packet = &StreamPacket{
 | 
				
			||||||
		t:         d.tag,
 | 
							t:         d.tag,
 | 
				
			||||||
		l:         *d.len,
 | 
							l:         *d.len,
 | 
				
			||||||
		vbuf:      buf.Bytes(),
 | 
							vBuf:      buf.Bytes(),
 | 
				
			||||||
		chunkMode: false,
 | 
							chunkMode: false,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										12
									
								
								encoder.go
								
								
								
								
							
							
						
						
									
										12
									
								
								encoder.go
								
								
								
								
							| 
						 | 
					@ -19,7 +19,7 @@ type Encoder struct {
 | 
				
			||||||
	isStreamMode  bool
 | 
						isStreamMode  bool
 | 
				
			||||||
	valBuf        *bytes.Buffer
 | 
						valBuf        *bytes.Buffer
 | 
				
			||||||
	done          bool
 | 
						done          bool
 | 
				
			||||||
	seqID         int
 | 
						seqId         int
 | 
				
			||||||
	isNodeMode    bool
 | 
						isNodeMode    bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,8 +29,8 @@ func (b *Encoder) SetSeqId(seqId int, isNode bool) {
 | 
				
			||||||
	// init
 | 
						// init
 | 
				
			||||||
	b.valBuf = new(bytes.Buffer)
 | 
						b.valBuf = new(bytes.Buffer)
 | 
				
			||||||
	b.nodes = make(map[int]Packet)
 | 
						b.nodes = make(map[int]Packet)
 | 
				
			||||||
	// set seqID
 | 
						// set seqId
 | 
				
			||||||
	b.seqID = seqId
 | 
						b.seqId = seqId
 | 
				
			||||||
	b.isNodeMode = isNode
 | 
						b.isNodeMode = isNode
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -119,7 +119,7 @@ func (b *Encoder) Packet() (Packet, error) {
 | 
				
			||||||
			t:         b.tag,
 | 
								t:         b.tag,
 | 
				
			||||||
			l:         *b.len,
 | 
								l:         *b.len,
 | 
				
			||||||
			vr:        b.valReader,
 | 
								vr:        b.valReader,
 | 
				
			||||||
			vbuf:      b.valBuf.Bytes(),
 | 
								vBuf:      b.valBuf.Bytes(),
 | 
				
			||||||
			chunkMode: true,
 | 
								chunkMode: true,
 | 
				
			||||||
			chunkSize: b.valReaderSize,
 | 
								chunkSize: b.valReaderSize,
 | 
				
			||||||
		}, err
 | 
							}, err
 | 
				
			||||||
| 
						 | 
					@ -129,14 +129,14 @@ func (b *Encoder) Packet() (Packet, error) {
 | 
				
			||||||
	return &StreamPacket{
 | 
						return &StreamPacket{
 | 
				
			||||||
		t:         b.tag,
 | 
							t:         b.tag,
 | 
				
			||||||
		l:         *b.len,
 | 
							l:         *b.len,
 | 
				
			||||||
		vbuf:      b.valBuf.Bytes(),
 | 
							vBuf:      b.valBuf.Bytes(),
 | 
				
			||||||
		chunkMode: false,
 | 
							chunkMode: false,
 | 
				
			||||||
	}, err
 | 
						}, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// will generate T of a TLV.
 | 
					// will generate T of a TLV.
 | 
				
			||||||
func (b *Encoder) generateT() error {
 | 
					func (b *Encoder) generateT() error {
 | 
				
			||||||
	t, err := spec.NewT(b.seqID)
 | 
						t, err := spec.NewT(b.seqId)
 | 
				
			||||||
	t.SetNodeMode(b.isNodeMode)
 | 
						t.SetNodeMode(b.isNodeMode)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,8 +4,8 @@ import (
 | 
				
			||||||
	"git.hpds.cc/Component/mq_coder/encoding"
 | 
						"git.hpds.cc/Component/mq_coder/encoding"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SetUTF8StringV set utf-8 string type value as V
 | 
					// SetUtf8StringV set utf-8 string type value as V
 | 
				
			||||||
func (b *Encoder) SetUTF8StringV(v string) {
 | 
					func (b *Encoder) SetUtf8StringV(v string) {
 | 
				
			||||||
	buf := []byte(v)
 | 
						buf := []byte(v)
 | 
				
			||||||
	b.SetBytesV(buf)
 | 
						b.SetBytesV(buf)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -102,7 +102,7 @@ func (p *StreamPacket) BytesV() []byte {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// UTF8StringV return V as utf-8 string
 | 
					// UTF8StringV return V as utf-8 string
 | 
				
			||||||
func (p *StreamPacket) UTF8StringV() string {
 | 
					func (p *StreamPacket) Utf8StringV() string {
 | 
				
			||||||
	return string(p.vBuf)
 | 
						return string(p.vBuf)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,7 @@ import (
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	maxSeqID     = 0x3F
 | 
						maxSeqId     = 0x3F
 | 
				
			||||||
	flagBitNode  = 0x80
 | 
						flagBitNode  = 0x80
 | 
				
			||||||
	wipeFlagBits = 0x3F
 | 
						wipeFlagBits = 0x3F
 | 
				
			||||||
	msb          = 0x80
 | 
						msb          = 0x80
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,12 +10,12 @@ type T byte
 | 
				
			||||||
// NewT returns a T with sequenceID. If this packet contains other
 | 
					// NewT returns a T with sequenceID. If this packet contains other
 | 
				
			||||||
// packets, this packet will be a "node packet", the T of this packet
 | 
					// packets, this packet will be a "node packet", the T of this packet
 | 
				
			||||||
// will set MSB to T.
 | 
					// will set MSB to T.
 | 
				
			||||||
func NewT(seqID int) (T, error) {
 | 
					func NewT(seqId int) (T, error) {
 | 
				
			||||||
	if seqID < 0 || seqID > maxSeqID {
 | 
						if seqId < 0 || seqId > maxSeqId {
 | 
				
			||||||
		return 0, errInvalidSeqId
 | 
							return 0, errInvalidSeqId
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return T(seqID), nil
 | 
						return T(seqId), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Sid returns the sequenceId of this packet.
 | 
					// Sid returns the sequenceId of this packet.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,6 @@ import (
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"git.hpds.cc/Component/mq_coder/encoding"
 | 
						"git.hpds.cc/Component/mq_coder/encoding"
 | 
				
			||||||
	//"mq_coder/encoding"
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// L is the Length in a TLV structure
 | 
					// L is the Length in a TLV structure
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue