Documentation ¶
Index ¶
- Constants
- Variables
- func MatchTopic(mask string, topic string) bool
- func WriteLength(len int) []byte
- func WritePacket(conn net.Conn, pkt Packet, debug bool) error
- type ConnAckPacket
- type ConnPacket
- type DisconnectPacket
- type Packet
- type PacketImpl
- 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
- type WillMessage
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") 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 WriteLength ¶ added in v0.1.2
Types ¶
type ConnAckPacket ¶
type ConnAckPacket struct { PacketImpl Header byte Session bool ReturnCode uint8 }
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 { PacketImpl Header byte ClientID string KeepAlive uint16 Username string Password string CleanSession bool Will *WillMessage 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 { PacketImpl 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 PacketImpl ¶ added in v0.2.5
type PacketImpl struct {
ClientId string
}
func (*PacketImpl) Length ¶ added in v0.2.5
func (pi *PacketImpl) Length() int
func (*PacketImpl) Pack ¶ added in v0.2.5
func (pi *PacketImpl) Pack() []byte
func (*PacketImpl) SetSource ¶ added in v0.2.5
func (pi *PacketImpl) SetSource(clientId string)
func (*PacketImpl) Source ¶ added in v0.2.5
func (pi *PacketImpl) Source() string
func (*PacketImpl) String ¶ added in v0.2.5
func (pi *PacketImpl) String() string
func (*PacketImpl) Type ¶ added in v0.2.5
func (pi *PacketImpl) Type() Type
func (*PacketImpl) Unpack ¶ added in v0.2.5
func (pi *PacketImpl) Unpack(buf []byte) error
type PingPacket ¶
type PingPacket struct { PacketImpl 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 { PacketImpl 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 ¶
type PubAckPacket struct { PacketImpl Header byte Id uint16 }
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 ¶
type PubCompPacket struct { PacketImpl Header byte Id uint16 }
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 ¶
type PubRecPacket struct { PacketImpl Header byte Id uint16 }
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 ¶
type PubRelPacket struct { PacketImpl Header byte Id uint16 }
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 { PacketImpl 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 ¶
type SubAckPacket struct { PacketImpl Header byte Id uint16 ReturnCodes []QoS }
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 { PacketImpl 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 ¶
type UnSubAckPacket struct { PacketImpl Header byte Id uint16 }
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 { PacketImpl 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
type WillMessage ¶ added in v0.2.5
type WillMessage struct { Flag bool QoS QoS Retain bool Dublicate bool Topic string Payload string }
func (*WillMessage) Length ¶ added in v0.2.5
func (m *WillMessage) Length() int
func (*WillMessage) Pack ¶ added in v0.2.5
func (m *WillMessage) Pack() []byte
func (*WillMessage) String ¶ added in v0.2.5
func (m *WillMessage) String() string
func (*WillMessage) Type ¶ added in v0.2.5
func (m *WillMessage) Type() Type
func (*WillMessage) Unpack ¶ added in v0.2.5
func (m *WillMessage) Unpack(buf []byte) error
Source Files ¶
- 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
- message_will.go
- packet.go
- packet_impl.go
- qos.go
Click to show internal directories.
Click to hide internal directories.