utp

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Accepted                     = 0x00
	ErrRefusedBadProtocolVersion = 0x01
	ErrRefusedIDRejected         = 0x02
	ErrRefusedbADID              = 0x03
	ErrRefusedServerUnavailable  = 0x04
	ErrNotAuthorised             = 0x05
	ErrBadRequest                = 0x06
)

Below are the const definitions for error codes returned by Connect()

Variables

This section is empty.

Functions

This section is empty.

Types

type Connect

type Connect struct {
	Version             int32
	InsecureFlag        bool
	ClientID            string
	KeepAlive           int32
	CleanSessFlag       bool
	SessKey             int32
	Username            string
	Password            []byte
	BatchDuration       int32
	BatchByteThreshold  int32
	BatchCountThreshold int32
}

Connect represents a connect Message.

func (*Connect) FromBinary

func (c *Connect) FromBinary(fh FixedHeader, data []byte)

func (*Connect) Info

func (c *Connect) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Connect) ToBinary

func (c *Connect) ToBinary() (bytes.Buffer, error)

func (*Connect) Type

func (c *Connect) Type() MessageType

Type returns the Message type.

type ConnectAcknowledge

type ConnectAcknowledge struct {
	ReturnCode uint8
	Epoch      int32
	ConnID     int32
}

ConnectAcknowledge represents a CONNECT Acknowledge Message. 0x00 connection accepted 0x01 refused: unacceptable proto version 0x02 refused: identifier rejected 0x03 refused: unacceptable identifier, access not allowed 0x04 refused server unavailiable 0x05 not authorized 0x06 bad request

func (*ConnectAcknowledge) FromBinary

func (c *ConnectAcknowledge) FromBinary(fh FixedHeader, data []byte)

func (*ConnectAcknowledge) Info

func (c *ConnectAcknowledge) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*ConnectAcknowledge) ToBinary

func (c *ConnectAcknowledge) ToBinary() (bytes.Buffer, error)

func (*ConnectAcknowledge) Type

func (c *ConnectAcknowledge) Type() MessageType

Type returns the Message type.

type ControlMessage

type ControlMessage struct {
	MessageID   uint16
	MessageType MessageType
	FlowControl FlowControl
	Message     []byte
}

func (*ControlMessage) FromBinary

func (c *ControlMessage) FromBinary(fh FixedHeader, data []byte)

func (*ControlMessage) Info

func (c *ControlMessage) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*ControlMessage) ToBinary

func (c *ControlMessage) ToBinary() (bytes.Buffer, error)

ToBinary encodes the Control Message into binary data

func (*ControlMessage) Type

func (c *ControlMessage) Type() MessageType

Type returns the Message type.

type Disconnect

type Disconnect struct {
	MessageID uint16
}

Disconnect is to signal you want to cease communications with the server

func (*Disconnect) FromBinary

func (d *Disconnect) FromBinary(fh FixedHeader, data []byte)

func (*Disconnect) Info

func (d *Disconnect) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Disconnect) ToBinary

func (d *Disconnect) ToBinary() (bytes.Buffer, error)

func (*Disconnect) Type

func (d *Disconnect) Type() MessageType

Type returns the Message type.

type FixedHeader

type FixedHeader struct {
	MessageType   MessageType
	FlowControl   FlowControl
	MessageLength int
}

FixedHeader

func (*FixedHeader) FromBinary

func (fh *FixedHeader) FromBinary(r io.Reader) error

type FlowControl

type FlowControl uint8

FlowControl represents FlowControl Message type

const (
	// Flow Control
	NONE FlowControl = iota
	ACKNOWLEDGE
	NOTIFY
	RECEIVE
	RECEIPT
	COMPLETE
)

type Info

type Info struct {
	DeliveryMode uint8
	MessageID    uint16
}

Info returns Qos and MessageID by the Info() function called on the Packet

type MessageType

type MessageType uint8

MessageType represents a Message type

const (
	// Message
	CONNECT MessageType = iota + 1
	PUBLISH
	RELAY
	SUBSCRIBE
	UNSUBSCRIBE
	PINGREQ
	DISCONNECT
	FLOWCONTROL
)

type Pingreq

type Pingreq struct {
}

Pingreq is a keepalive

func (*Pingreq) FromBinary

func (p *Pingreq) FromBinary(fh FixedHeader, data []byte)

func (*Pingreq) Info

func (p *Pingreq) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Pingreq) ToBinary

func (p *Pingreq) ToBinary() (bytes.Buffer, error)

func (*Pingreq) Type

func (p *Pingreq) Type() MessageType

Type returns the Message type.

type Publish

type Publish struct {
	IsForwarded  bool
	MessageID    uint16
	DeliveryMode uint8
	Messages     []*PublishMessage
}

Publish represents a publish Messages.

func (*Publish) FromBinary

func (p *Publish) FromBinary(fh FixedHeader, data []byte)

func (*Publish) Info

func (p *Publish) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Publish) ToBinary

func (p *Publish) ToBinary() (bytes.Buffer, error)

func (*Publish) Type

func (p *Publish) Type() MessageType

Type returns the Message type.

type PublishMessage

type PublishMessage struct {
	Topic   string
	Payload []byte
	Ttl     string
}

PublishMessage reprensents a publish Message

type Relay

type Relay struct {
	IsForwarded   bool
	MessageID     uint16
	RelayRequests []*RelayRequest
}

Relay tells the server which topics and last durations the client would like get data. The Delivery Mode for relay is EXPRESS.

func (*Relay) FromBinary

func (r *Relay) FromBinary(fh FixedHeader, data []byte)

func (*Relay) Info

func (r *Relay) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Relay) ToBinary

func (r *Relay) ToBinary() (bytes.Buffer, error)

func (*Relay) Type

func (r *Relay) Type() MessageType

Type returns the Message type.

type RelayRequest

type RelayRequest struct {
	Topic string
	Last  string
}

RelayRequest is pairing the Topic and Last parameter together

type Subscribe

type Subscribe struct {
	IsForwarded   bool
	MessageID     uint16
	Subscriptions []*Subscription
}

Subscribe tells the server which topics the client would like to subscribe to

func (*Subscribe) FromBinary

func (s *Subscribe) FromBinary(fh FixedHeader, data []byte)

func (*Subscribe) Info

func (s *Subscribe) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Subscribe) ToBinary

func (s *Subscribe) ToBinary() (bytes.Buffer, error)

func (*Subscribe) Type

func (s *Subscribe) Type() MessageType

Type returns the Message type.

type Subscription

type Subscription struct {
	DeliveryMode uint8
	Delay        int32
	Topic        string
}

Subscription is a struct for pairing the delivery mode and topic together for the delivery mode's pairs in unsubscribe and subscribe

type Unsubscribe

type Unsubscribe struct {
	IsForwarded   bool
	MessageID     uint16
	Subscriptions []*Subscription
}

Unsubscribe is the Message to send if you don't want to subscribe to a topic anymore

func (*Unsubscribe) FromBinary

func (u *Unsubscribe) FromBinary(fh FixedHeader, data []byte)

func (*Unsubscribe) Info

func (u *Unsubscribe) Info() Info

Info returns DeliveryMode and MessageID of this Message.

func (*Unsubscribe) ToBinary

func (u *Unsubscribe) ToBinary() (bytes.Buffer, error)

func (*Unsubscribe) Type

func (u *Unsubscribe) Type() MessageType

Type returns the Message type.

Jump to

Keyboard shortcuts

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