mqtt

package
v0.0.0-...-e5a160e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadVarint

func ReadVarint(reader io.Reader) (int, error)

func WriteMessageTo

func WriteMessageTo(message Message, w io.Writer) (int64, error)

func WriteVarint

func WriteVarint(writer io.Writer, size int) (int, error)

Types

type ConnackMessage

type ConnackMessage struct {
	FixedHeader
	Reserved   uint8
	ReturnCode uint8
}

func NewConnackMessage

func NewConnackMessage() *ConnackMessage

func (*ConnackMessage) String

func (self *ConnackMessage) String() string

func (ConnackMessage) WriteTo

func (self ConnackMessage) WriteTo(w io.Writer) (int64, error)

type ConnectMessage

type ConnectMessage struct {
	FixedHeader
	Magic        []byte       `json:"magic"`
	Version      uint8        `json:"version"`
	Flag         uint8        `json:"flag"`
	KeepAlive    uint16       `json:"keep_alive"`
	Identifier   string       `json:"identifier"`
	Will         *WillMessage `json:"will"`
	CleanSession bool         `json:clean_session`
	UserName     []byte       `json:"user_name"`
	Password     []byte       `json:"password"`
}

func NewConnectMessage

func NewConnectMessage() *ConnectMessage

func (*ConnectMessage) String

func (self *ConnectMessage) String() string

func (*ConnectMessage) WriteTo

func (self *ConnectMessage) WriteTo(w io.Writer) (int64, error)

type DisconnectMessage

type DisconnectMessage struct {
	FixedHeader
}

func NewDisconnectMessage

func NewDisconnectMessage() *DisconnectMessage

func (*DisconnectMessage) String

func (self *DisconnectMessage) String() string

func (DisconnectMessage) WriteTo

func (self DisconnectMessage) WriteTo(w io.Writer) (int64, error)

type FixedHeader

type FixedHeader struct {
	Type            PacketType
	Dupe            bool
	QosLevel        int
	Retain          int
	RemainingLength int
}

func (*FixedHeader) GetType

func (self *FixedHeader) GetType() PacketType

func (*FixedHeader) GetTypeAsString

func (self *FixedHeader) GetTypeAsString() string

func (*FixedHeader) String

func (self *FixedHeader) String() string

type Message

type Message interface {
	GetType() PacketType
	GetTypeAsString() string
}

func CopyMessage

func CopyMessage(msg Message) (Message, error)

func ParseMessage

func ParseMessage(reader io.Reader, max_length int) (Message, error)

TODO: このアホっぽい感じどうにかしたいなー TODO: 読み込んだサイズ返す

type PacketType

type PacketType int
const (
	PACKET_TYPE_RESERVED1   PacketType = 0
	PACKET_TYPE_CONNECT     PacketType = 1
	PACKET_TYPE_CONNACK     PacketType = 2
	PACKET_TYPE_PUBLISH     PacketType = 3
	PACKET_TYPE_PUBACK      PacketType = 4
	PACKET_TYPE_PUBREC      PacketType = 5
	PACKET_TYPE_PUBREL      PacketType = 6
	PACKET_TYPE_PUBCOMP     PacketType = 7
	PACKET_TYPE_SUBSCRIBE   PacketType = 8
	PACKET_TYPE_SUBACK      PacketType = 9
	PACKET_TYPE_UNSUBSCRIBE PacketType = 10
	PACKET_TYPE_UNSUBACK    PacketType = 11
	PACKET_TYPE_PINGREQ     PacketType = 12
	PACKET_TYPE_PINGRESP    PacketType = 13
	PACKET_TYPE_DISCONNECT  PacketType = 14
	PACKET_TYPE_RESERVED2   PacketType = 15
)

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

func (ParseError) Error

func (self ParseError) Error() string

type PingreqMessage

type PingreqMessage struct {
	FixedHeader
}

func NewPingreqMessage

func NewPingreqMessage() *PingreqMessage

func (*PingreqMessage) String

func (self *PingreqMessage) String() string

func (*PingreqMessage) WriteTo

func (self *PingreqMessage) WriteTo(w io.Writer) (int64, error)

type PingrespMessage

type PingrespMessage struct {
	FixedHeader
}

func NewPingrespMessage

func NewPingrespMessage() *PingrespMessage

func (*PingrespMessage) String

func (self *PingrespMessage) String() string

func (PingrespMessage) WriteTo

func (self PingrespMessage) WriteTo(w io.Writer) (int64, error)

type PubackMessage

type PubackMessage struct {
	FixedHeader
	PacketIdentifier uint16
}

func NewPubackMessage

func NewPubackMessage() *PubackMessage

func (*PubackMessage) String

func (self *PubackMessage) String() string

func (*PubackMessage) WriteTo

func (self *PubackMessage) WriteTo(w io.Writer) (int64, error)

type PubcompMessage

type PubcompMessage struct {
	FixedHeader
	PacketIdentifier uint16
}

func NewPubcompMessage

func NewPubcompMessage() *PubcompMessage

func (*PubcompMessage) String

func (self *PubcompMessage) String() string

func (*PubcompMessage) WriteTo

func (self *PubcompMessage) WriteTo(w io.Writer) (int64, error)

type PublishMessage

type PublishMessage struct {
	FixedHeader      `json:"header"`
	TopicName        string      `json:"topic_name"`
	PacketIdentifier uint16      `json:"identifier"`
	Payload          []byte      `json:"payload"`
	Opaque           interface{} `json:"-"`
}

func CopyPublishMessage

func CopyPublishMessage(msg *PublishMessage) (*PublishMessage, error)

func MustCopyPublishMessage

func MustCopyPublishMessage(msg *PublishMessage) *PublishMessage

func NewPublishMessage

func NewPublishMessage() *PublishMessage

func (*PublishMessage) String

func (self *PublishMessage) String() string

func (*PublishMessage) WriteTo

func (self *PublishMessage) WriteTo(w io.Writer) (int64, error)

type PubrecMessage

type PubrecMessage struct {
	FixedHeader
	PacketIdentifier uint16
}

func NewPubrecMessage

func NewPubrecMessage() *PubrecMessage

func (*PubrecMessage) String

func (self *PubrecMessage) String() string

func (*PubrecMessage) WriteTo

func (self *PubrecMessage) WriteTo(w io.Writer) (int64, error)

type PubrelMessage

type PubrelMessage struct {
	FixedHeader
	PacketIdentifier uint16
}

func NewPubrelMessage

func NewPubrelMessage() *PubrelMessage

func (*PubrelMessage) String

func (self *PubrelMessage) String() string

func (*PubrelMessage) WriteTo

func (self *PubrelMessage) WriteTo(w io.Writer) (int64, error)

type ReturnCode

type ReturnCode int
const (
	CONNECTION_ACCEOTED                              ReturnCode = 1
	CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION ReturnCode = 2
	CONNECTION_REFUSED_IDENTIFIER_REJECTED           ReturnCode = 3
	CONNECTION_REFUSED_SERVER_UNAVAILABLE            ReturnCode = 4
	CONNECTION_REFUSED_BAD_USER_NAME_OR_PASSWORD     ReturnCode = 5
	CONNECTION_REFUSED_NOT_AUTHORIZED                ReturnCode = 6
)

type SubackMessage

type SubackMessage struct {
	FixedHeader
	PacketIdentifier uint16
	Qos              []byte
}

func NewSubackMessage

func NewSubackMessage() *SubackMessage

func (*SubackMessage) String

func (self *SubackMessage) String() string

func (*SubackMessage) WriteTo

func (self *SubackMessage) WriteTo(w io.Writer) (int64, error)

type SubscribeMessage

type SubscribeMessage struct {
	FixedHeader
	PacketIdentifier uint16
	Payload          []SubscribePayload
}

func NewSubscribeMessage

func NewSubscribeMessage() *SubscribeMessage

func (*SubscribeMessage) String

func (self *SubscribeMessage) String() string

func (*SubscribeMessage) WriteTo

func (self *SubscribeMessage) WriteTo(w io.Writer) (int64, error)

type SubscribePayload

type SubscribePayload struct {
	TopicPath    string
	RequestedQos uint8
}

type UnsubackMessage

type UnsubackMessage struct {
	FixedHeader
	PacketIdentifier uint16
}

func NewUnsubackMessage

func NewUnsubackMessage() *UnsubackMessage

func (*UnsubackMessage) String

func (self *UnsubackMessage) String() string

func (*UnsubackMessage) WriteTo

func (self *UnsubackMessage) WriteTo(w io.Writer) (int64, error)

type UnsubscribeMessage

type UnsubscribeMessage struct {
	FixedHeader
	TopicName        string
	PacketIdentifier uint16
	Payload          []SubscribePayload
}

func NewUnsubscribeMessage

func NewUnsubscribeMessage() *UnsubscribeMessage

func (*UnsubscribeMessage) String

func (self *UnsubscribeMessage) String() string

func (*UnsubscribeMessage) WriteTo

func (self *UnsubscribeMessage) WriteTo(w io.Writer) (int64, error)

type WillMessage

type WillMessage struct {
	Qos     uint8  `json:"qos"`
	Topic   string `json:"topic"`
	Message string `json:"message"`
	Retain  bool   `json:retain`
}

func (*WillMessage) Size

func (self *WillMessage) Size() int

func (*WillMessage) String

func (self *WillMessage) String() string

func (*WillMessage) WriteTo

func (self *WillMessage) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL