packets

package
v0.0.0-...-087b33b Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2017 License: EPL-1.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CONNECT     = 1
	CONNACK     = 2
	PUBLISH     = 3
	PUBACK      = 4
	PUBREC      = 5
	PUBREL      = 6
	PUBCOMP     = 7
	SUBSCRIBE   = 8
	SUBACK      = 9
	UNSUBSCRIBE = 10
	UNSUBACK    = 11
	PINGREQ     = 12
	PINGRESP    = 13
	DISCONNECT  = 14
)
View Source
const (
	CONN_ACCEPTED           = 0x00
	CONN_REF_BAD_PROTO_VER  = 0x01
	CONN_REF_ID_REJ         = 0x02
	CONN_REF_SERV_UNAVAIL   = 0x03
	CONN_REF_BAD_USER_PASS  = 0x04
	CONN_REF_NOT_AUTH       = 0x05
	CONN_NETWORK_ERROR      = 0xFE
	CONN_PROTOCOL_VIOLATION = 0xFF
)

Variables

View Source
var ConnackReturnCodes = map[uint8]string{
	0:   "Connection Accepted",
	1:   "Connection Refused: Bad Protocol Version",
	2:   "Connection Refused: Client Identifier Rejected",
	3:   "Connection Refused: Server Unavailable",
	4:   "Connection Refused: Username or Password in unknown format",
	5:   "Connection Refused: Not Authorised",
	254: "Connection Error",
	255: "Connection Refused: Protocol Violation",
}
View Source
var PacketNames = map[uint8]string{
	1:  "CONNECT",
	2:  "CONNACK",
	3:  "PUBLISH",
	4:  "PUBACK",
	5:  "PUBREC",
	6:  "PUBREL",
	7:  "PUBCOMP",
	8:  "SUBSCRIBE",
	9:  "SUBACK",
	10: "UNSUBSCRIBE",
	11: "UNSUBACK",
	12: "PINGREQ",
	13: "PINGRESP",
	14: "DISCONNECT",
}

Functions

This section is empty.

Types

type ConnackPacket

type ConnackPacket struct {
	FixedHeader
	TopicNameCompression byte
	ReturnCode           byte
	// contains filtered or unexported fields
}

func (*ConnackPacket) Details

func (ca *ConnackPacket) Details() Details

func (*ConnackPacket) String

func (ca *ConnackPacket) String() string

func (*ConnackPacket) UUID

func (ca *ConnackPacket) UUID() uuid.UUID

func (*ConnackPacket) Unpack

func (ca *ConnackPacket) Unpack(b io.Reader)

func (*ConnackPacket) Write

func (ca *ConnackPacket) Write(w io.Writer) error

type ConnectPacket

type ConnectPacket struct {
	FixedHeader
	ProtocolName    string
	ProtocolVersion byte
	CleanSession    bool
	WillFlag        bool
	WillQos         byte
	WillRetain      bool
	UsernameFlag    bool
	PasswordFlag    bool
	ReservedBit     byte
	KeepaliveTimer  uint16

	ClientIdentifier string
	WillTopic        string
	WillMessage      []byte
	Username         string
	Password         []byte
	// contains filtered or unexported fields
}

func (*ConnectPacket) Details

func (c *ConnectPacket) Details() Details

func (*ConnectPacket) String

func (c *ConnectPacket) String() string

func (*ConnectPacket) UUID

func (c *ConnectPacket) UUID() uuid.UUID

func (*ConnectPacket) Unpack

func (c *ConnectPacket) Unpack(b io.Reader)

func (*ConnectPacket) Validate

func (c *ConnectPacket) Validate() byte

func (*ConnectPacket) Write

func (c *ConnectPacket) Write(w io.Writer) error

type ControlPacket

type ControlPacket interface {
	Write(io.Writer) error
	Unpack(io.Reader)
	String() string
	Details() Details
	UUID() uuid.UUID
}

func NewControlPacket

func NewControlPacket(packetType byte) (cp ControlPacket)

func NewControlPacketWithHeader

func NewControlPacketWithHeader(fh FixedHeader) (cp ControlPacket)

func ReadPacket

func ReadPacket(r io.Reader) (cp ControlPacket, err error)

type Details

type Details struct {
	Qos       byte
	MessageID uint16
}

type DisconnectPacket

type DisconnectPacket struct {
	FixedHeader
	// contains filtered or unexported fields
}

func (*DisconnectPacket) Details

func (d *DisconnectPacket) Details() Details

func (*DisconnectPacket) String

func (d *DisconnectPacket) String() string

func (*DisconnectPacket) UUID

func (d *DisconnectPacket) UUID() uuid.UUID

func (*DisconnectPacket) Unpack

func (d *DisconnectPacket) Unpack(b io.Reader)

func (*DisconnectPacket) Write

func (d *DisconnectPacket) Write(w io.Writer) error

type FixedHeader

type FixedHeader struct {
	MessageType     byte
	Dup             bool
	Qos             byte
	Retain          bool
	RemainingLength int
}

func (FixedHeader) String

func (fh FixedHeader) String() string

type PingreqPacket

type PingreqPacket struct {
	FixedHeader
	// contains filtered or unexported fields
}

func (*PingreqPacket) Details

func (pr *PingreqPacket) Details() Details

func (*PingreqPacket) String

func (pr *PingreqPacket) String() string

func (*PingreqPacket) UUID

func (pr *PingreqPacket) UUID() uuid.UUID

func (*PingreqPacket) Unpack

func (pr *PingreqPacket) Unpack(b io.Reader)

func (*PingreqPacket) Write

func (pr *PingreqPacket) Write(w io.Writer) error

type PingrespPacket

type PingrespPacket struct {
	FixedHeader
	// contains filtered or unexported fields
}

func (*PingrespPacket) Details

func (pr *PingrespPacket) Details() Details

func (*PingrespPacket) String

func (pr *PingrespPacket) String() string

func (*PingrespPacket) UUID

func (pr *PingrespPacket) UUID() uuid.UUID

func (*PingrespPacket) Unpack

func (pr *PingrespPacket) Unpack(b io.Reader)

func (*PingrespPacket) Write

func (pr *PingrespPacket) Write(w io.Writer) error

type PubackPacket

type PubackPacket struct {
	FixedHeader
	MessageID uint16
	// contains filtered or unexported fields
}

func (*PubackPacket) Details

func (pa *PubackPacket) Details() Details

func (*PubackPacket) String

func (pa *PubackPacket) String() string

func (*PubackPacket) UUID

func (pa *PubackPacket) UUID() uuid.UUID

func (*PubackPacket) Unpack

func (pa *PubackPacket) Unpack(b io.Reader)

func (*PubackPacket) Write

func (pa *PubackPacket) Write(w io.Writer) error

type PubcompPacket

type PubcompPacket struct {
	FixedHeader
	MessageID uint16
	// contains filtered or unexported fields
}

func (*PubcompPacket) Details

func (pc *PubcompPacket) Details() Details

func (*PubcompPacket) String

func (pc *PubcompPacket) String() string

func (*PubcompPacket) UUID

func (pc *PubcompPacket) UUID() uuid.UUID

func (*PubcompPacket) Unpack

func (pc *PubcompPacket) Unpack(b io.Reader)

func (*PubcompPacket) Write

func (pc *PubcompPacket) Write(w io.Writer) error

type PublishPacket

type PublishPacket struct {
	FixedHeader
	TopicName string
	MessageID uint16
	Payload   []byte
	// contains filtered or unexported fields
}

func (*PublishPacket) Copy

func (p *PublishPacket) Copy() *PublishPacket

func (*PublishPacket) Details

func (p *PublishPacket) Details() Details

func (*PublishPacket) String

func (p *PublishPacket) String() string

func (*PublishPacket) UUID

func (p *PublishPacket) UUID() uuid.UUID

func (*PublishPacket) Unpack

func (p *PublishPacket) Unpack(b io.Reader)

func (*PublishPacket) Write

func (p *PublishPacket) Write(w io.Writer) error

type PubrecPacket

type PubrecPacket struct {
	FixedHeader
	MessageID uint16
	// contains filtered or unexported fields
}

func (*PubrecPacket) Details

func (pr *PubrecPacket) Details() Details

func (*PubrecPacket) String

func (pr *PubrecPacket) String() string

func (*PubrecPacket) UUID

func (pr *PubrecPacket) UUID() uuid.UUID

func (*PubrecPacket) Unpack

func (pr *PubrecPacket) Unpack(b io.Reader)

func (*PubrecPacket) Write

func (pr *PubrecPacket) Write(w io.Writer) error

type PubrelPacket

type PubrelPacket struct {
	FixedHeader
	MessageID uint16
	// contains filtered or unexported fields
}

func (*PubrelPacket) Details

func (pr *PubrelPacket) Details() Details

func (*PubrelPacket) String

func (pr *PubrelPacket) String() string

func (*PubrelPacket) UUID

func (pr *PubrelPacket) UUID() uuid.UUID

func (*PubrelPacket) Unpack

func (pr *PubrelPacket) Unpack(b io.Reader)

func (*PubrelPacket) Write

func (pr *PubrelPacket) Write(w io.Writer) error

type SubackPacket

type SubackPacket struct {
	FixedHeader
	MessageID   uint16
	GrantedQoss []byte
	// contains filtered or unexported fields
}

func (*SubackPacket) Details

func (sa *SubackPacket) Details() Details

func (*SubackPacket) String

func (sa *SubackPacket) String() string

func (*SubackPacket) UUID

func (sa *SubackPacket) UUID() uuid.UUID

func (*SubackPacket) Unpack

func (sa *SubackPacket) Unpack(b io.Reader)

func (*SubackPacket) Write

func (sa *SubackPacket) Write(w io.Writer) error

type SubscribePacket

type SubscribePacket struct {
	FixedHeader
	MessageID uint16
	Topics    []string
	Qoss      []byte
	// contains filtered or unexported fields
}

func (*SubscribePacket) Details

func (s *SubscribePacket) Details() Details

func (*SubscribePacket) String

func (s *SubscribePacket) String() string

func (*SubscribePacket) UUID

func (s *SubscribePacket) UUID() uuid.UUID

func (*SubscribePacket) Unpack

func (s *SubscribePacket) Unpack(b io.Reader)

func (*SubscribePacket) Write

func (s *SubscribePacket) Write(w io.Writer) error

type UnsubackPacket

type UnsubackPacket struct {
	FixedHeader
	MessageID uint16
	// contains filtered or unexported fields
}

func (*UnsubackPacket) Details

func (ua *UnsubackPacket) Details() Details

func (*UnsubackPacket) String

func (ua *UnsubackPacket) String() string

func (*UnsubackPacket) UUID

func (ua *UnsubackPacket) UUID() uuid.UUID

func (*UnsubackPacket) Unpack

func (ua *UnsubackPacket) Unpack(b io.Reader)

func (*UnsubackPacket) Write

func (ua *UnsubackPacket) Write(w io.Writer) error

type UnsubscribePacket

type UnsubscribePacket struct {
	FixedHeader
	MessageID uint16
	Topics    []string
	// contains filtered or unexported fields
}

func (*UnsubscribePacket) Details

func (u *UnsubscribePacket) Details() Details

func (*UnsubscribePacket) String

func (u *UnsubscribePacket) String() string

func (*UnsubscribePacket) UUID

func (u *UnsubscribePacket) UUID() uuid.UUID

func (*UnsubscribePacket) Unpack

func (u *UnsubscribePacket) Unpack(b io.Reader)

func (*UnsubscribePacket) Write

func (u *UnsubscribePacket) Write(w io.Writer) error

Jump to

Keyboard shortcuts

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