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