Documentation ¶
Index ¶
- Constants
- Variables
- func MatchTopic(mask string, topic string) bool
- func ReadBytes(buf []byte, offset int, length int) ([]byte, int, error)
- func ReadInt16(buf []byte, offset int) (uint16, int, error)
- func ReadInt8(buf []byte, offset int) (uint8, int, error)
- func ReadString(buf []byte, offset int, length int) (string, int, error)
- func WriteBytes(buf []byte, offset int, bytes []byte) int
- func WriteInt16(buf []byte, offset int, value uint16) int
- func WriteInt8(buf []byte, offset int, value uint8) int
- func WriteLength(len int) []byte
- func WritePacket(conn net.Conn, pkt Packet, debug bool) error
- func WriteString(buf []byte, offset int, value string) int
- type ConnAckPacket
- type ConnPacket
- type DisconnectPacket
- type Message
- type Packet
- type PingPacket
- type PongPacket
- type PubAckPacket
- type PubCompPacket
- type PubRecPacket
- type PubRelPacket
- type PublishPacket
- type QoS
- type SubAckPacket
- type SubscribePacket
- type SubscribePayload
- type Type
- type UnSubAckPacket
- type UnSubscribePacket
Constants ¶
View Source
const ( ConnectAccepted int = iota ConnectUnacceptableProtocol ConnectIndentifierRejected ConnectBadUserPass ConnectNotAuthorized )
Variables ¶
View Source
var ( ErrInvalidPacketType = errors.New("invalid packet type") ErrProtocolError = errors.New("protocol error (not supported)") ErrInvalidPacketLength = errors.New("invalid packet Len") ErrUnknownPacket = errors.New("unknown packet type") ErrReadFromBuf = errors.New("error read data from buffer") ErrUnsupportedVersion = errors.New("unsupported mqtt version") ErrConnect = errors.New("error connect to broker") )
View Source
var ErrInvalidQos = errors.New("invalid qos")
Functions ¶
func MatchTopic ¶ added in v0.1.2
func WriteBytes ¶ added in v0.1.2
Write bytes array length and array itself into buffer return offset after write
func WriteLength ¶ added in v0.1.2
Types ¶
type ConnAckPacket ¶
func CreateConnAck ¶
func CreateConnAck(buf byte) *ConnAckPacket
func NewConnAck ¶
func NewConnAck() *ConnAckPacket
func (*ConnAckPacket) Length ¶
func (cack *ConnAckPacket) Length() int
func (*ConnAckPacket) Pack ¶
func (cack *ConnAckPacket) Pack() []byte
func (*ConnAckPacket) String ¶
func (cack *ConnAckPacket) String() string
func (*ConnAckPacket) Type ¶
func (cack *ConnAckPacket) Type() Type
func (*ConnAckPacket) Unpack ¶
func (cack *ConnAckPacket) Unpack(buf []byte) error
type ConnPacket ¶
type ConnPacket struct { Header byte ClientID string KeepAlive uint16 Username string Password string CleanSession bool Will *Message Version byte VersionName string }
func CreateConnect ¶
func CreateConnect(buf byte) *ConnPacket
func NewConnect ¶
func NewConnect() *ConnPacket
func (*ConnPacket) Length ¶
func (c *ConnPacket) Length() int
func (*ConnPacket) Pack ¶
func (c *ConnPacket) Pack() []byte
func (*ConnPacket) String ¶
func (c *ConnPacket) String() string
func (*ConnPacket) Type ¶
func (c *ConnPacket) Type() Type
func (*ConnPacket) Unpack ¶
func (c *ConnPacket) Unpack(buf []byte) error
type DisconnectPacket ¶
type DisconnectPacket struct {
Header byte
}
func CreateDisconnect ¶
func CreateDisconnect(buf byte) *DisconnectPacket
func NewDisconnect ¶
func NewDisconnect() *DisconnectPacket
func (*DisconnectPacket) Length ¶
func (cack *DisconnectPacket) Length() int
func (*DisconnectPacket) Pack ¶
func (cack *DisconnectPacket) Pack() []byte
func (*DisconnectPacket) String ¶
func (cack *DisconnectPacket) String() string
func (*DisconnectPacket) Type ¶
func (cack *DisconnectPacket) Type() Type
func (*DisconnectPacket) Unpack ¶
func (cack *DisconnectPacket) Unpack(buf []byte) error
type Packet ¶
type PingPacket ¶
type PingPacket struct {
Header byte
}
func CreatePing ¶
func CreatePing(buf byte) *PingPacket
func NewPing ¶
func NewPing() *PingPacket
func (*PingPacket) Length ¶
func (p *PingPacket) Length() int
func (*PingPacket) Pack ¶
func (p *PingPacket) Pack() []byte
func (*PingPacket) String ¶
func (p *PingPacket) String() string
func (*PingPacket) Type ¶
func (p *PingPacket) Type() Type
func (*PingPacket) Unpack ¶
func (p *PingPacket) Unpack(buf []byte) error
type PongPacket ¶
type PongPacket struct {
Header byte
}
func CreatePong ¶
func CreatePong(buf byte) *PongPacket
func NewPong ¶
func NewPong() *PongPacket
func (*PongPacket) Length ¶
func (p *PongPacket) Length() int
func (*PongPacket) Pack ¶
func (p *PongPacket) Pack() []byte
func (*PongPacket) String ¶
func (p *PongPacket) String() string
func (*PongPacket) Type ¶
func (p *PongPacket) Type() Type
func (*PongPacket) Unpack ¶
func (p *PongPacket) Unpack(buf []byte) error
type PubAckPacket ¶
func CreatePubAck ¶
func CreatePubAck(buf byte) *PubAckPacket
func NewPubAck ¶
func NewPubAck() *PubAckPacket
func (*PubAckPacket) Length ¶
func (pack *PubAckPacket) Length() int
func (*PubAckPacket) Pack ¶
func (pack *PubAckPacket) Pack() []byte
func (*PubAckPacket) String ¶
func (pack *PubAckPacket) String() string
func (*PubAckPacket) Type ¶
func (pack *PubAckPacket) Type() Type
func (*PubAckPacket) Unpack ¶
func (pack *PubAckPacket) Unpack(buf []byte) error
type PubCompPacket ¶
func CreatePubComp ¶
func CreatePubComp(buf byte) *PubCompPacket
func NewPubComp ¶
func NewPubComp() *PubCompPacket
func (*PubCompPacket) Length ¶
func (p *PubCompPacket) Length() int
func (*PubCompPacket) Pack ¶
func (p *PubCompPacket) Pack() []byte
func (*PubCompPacket) String ¶
func (p *PubCompPacket) String() string
func (*PubCompPacket) Type ¶
func (p *PubCompPacket) Type() Type
func (*PubCompPacket) Unpack ¶
func (p *PubCompPacket) Unpack(buf []byte) error
type PubRecPacket ¶
func CreatePubRec ¶
func CreatePubRec(buf byte) *PubRecPacket
func NewPubRec ¶
func NewPubRec() *PubRecPacket
func (*PubRecPacket) Length ¶
func (p *PubRecPacket) Length() int
func (*PubRecPacket) Pack ¶
func (p *PubRecPacket) Pack() []byte
func (*PubRecPacket) String ¶
func (p *PubRecPacket) String() string
func (*PubRecPacket) Type ¶
func (p *PubRecPacket) Type() Type
func (*PubRecPacket) Unpack ¶
func (p *PubRecPacket) Unpack(buf []byte) error
type PubRelPacket ¶
func CreatePubRel ¶
func CreatePubRel(buf byte) *PubRelPacket
func NewPubRel ¶
func NewPubRel() *PubRelPacket
func (*PubRelPacket) Length ¶
func (p *PubRelPacket) Length() int
func (*PubRelPacket) Pack ¶
func (p *PubRelPacket) Pack() []byte
func (*PubRelPacket) String ¶
func (p *PubRelPacket) String() string
func (*PubRelPacket) Type ¶
func (p *PubRelPacket) Type() Type
func (*PubRelPacket) Unpack ¶
func (p *PubRelPacket) Unpack(buf []byte) error
type PublishPacket ¶
type PublishPacket struct { Header byte Id uint16 QoS QoS Retain bool DUP bool Topic string Payload string }
func CreatePublish ¶
func CreatePublish(buf byte) *PublishPacket
func NewPublish ¶
func NewPublish() *PublishPacket
func (*PublishPacket) Length ¶
func (p *PublishPacket) Length() int
func (*PublishPacket) Pack ¶
func (p *PublishPacket) Pack() []byte
func (*PublishPacket) String ¶
func (p *PublishPacket) String() string
func (*PublishPacket) Type ¶
func (p *PublishPacket) Type() Type
func (*PublishPacket) Unpack ¶
func (p *PublishPacket) Unpack(buf []byte) error
type SubAckPacket ¶
func CreateSubAck ¶
func CreateSubAck(buf byte) *SubAckPacket
func NewSubAck ¶
func NewSubAck() *SubAckPacket
func (*SubAckPacket) Length ¶
func (sack *SubAckPacket) Length() int
func (*SubAckPacket) Pack ¶
func (sack *SubAckPacket) Pack() []byte
func (*SubAckPacket) String ¶
func (sack *SubAckPacket) String() string
func (*SubAckPacket) Type ¶
func (sack *SubAckPacket) Type() Type
func (*SubAckPacket) Unpack ¶
func (sack *SubAckPacket) Unpack(buf []byte) error
type SubscribePacket ¶
type SubscribePacket struct { Header byte Id uint16 Topics []SubscribePayload }
func CreateSubscribe ¶
func CreateSubscribe(buf byte) *SubscribePacket
func NewSubscribe ¶
func NewSubscribe() *SubscribePacket
func (*SubscribePacket) Length ¶
func (s *SubscribePacket) Length() int
func (*SubscribePacket) Pack ¶
func (s *SubscribePacket) Pack() []byte
func (*SubscribePacket) String ¶
func (s *SubscribePacket) String() string
func (*SubscribePacket) Type ¶
func (s *SubscribePacket) Type() Type
func (*SubscribePacket) Unpack ¶
func (s *SubscribePacket) Unpack(buf []byte) error
type SubscribePayload ¶
func (*SubscribePayload) Length ¶
func (p *SubscribePayload) Length() int
func (*SubscribePayload) Pack ¶
func (p *SubscribePayload) Pack() []byte
func (*SubscribePayload) String ¶
func (p *SubscribePayload) String() string
type UnSubAckPacket ¶
func CreateUnSubAck ¶
func CreateUnSubAck(buf byte) *UnSubAckPacket
func NewUnSubAck ¶
func NewUnSubAck() *UnSubAckPacket
func (*UnSubAckPacket) Length ¶
func (uack *UnSubAckPacket) Length() int
func (*UnSubAckPacket) Pack ¶
func (uack *UnSubAckPacket) Pack() []byte
func (*UnSubAckPacket) String ¶
func (uack *UnSubAckPacket) String() string
func (*UnSubAckPacket) Type ¶
func (uack *UnSubAckPacket) Type() Type
func (*UnSubAckPacket) Unpack ¶
func (uack *UnSubAckPacket) Unpack(buf []byte) error
type UnSubscribePacket ¶
type UnSubscribePacket struct { Header byte Id uint16 Topics []SubscribePayload }
func CreateUnSubscribe ¶
func CreateUnSubscribe(buf byte) *UnSubscribePacket
func NewUnSub ¶
func NewUnSub() *UnSubscribePacket
func (*UnSubscribePacket) Length ¶
func (u *UnSubscribePacket) Length() int
func (*UnSubscribePacket) Pack ¶
func (u *UnSubscribePacket) Pack() []byte
func (*UnSubscribePacket) String ¶
func (u *UnSubscribePacket) String() string
func (*UnSubscribePacket) Type ¶
func (u *UnSubscribePacket) Type() Type
func (*UnSubscribePacket) Unpack ¶
func (u *UnSubscribePacket) Unpack(buf []byte) error
Source Files ¶
- message.go
- message_connack.go
- message_connect.go
- message_disconnect.go
- message_ping.go
- message_pong.go
- message_puback.go
- message_pubcomp.go
- message_publish.go
- message_publishrel.go
- message_pubrec.go
- message_suback.go
- message_subscribe.go
- message_unsuback.go
- message_unusubscribe.go
- packet.go
- qos.go
- utils.go
Click to show internal directories.
Click to hide internal directories.