connection

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// On parent session callbacks
	On OnProcess

	// Conn is network connection
	Conn io.Closer

	// PacketsMetric interface to metric packets
	PacketsMetric systree.PacketsMetric

	// ID ClientID
	ID string

	// KeepAlive
	KeepAlive int

	// ProtoVersion MQTT protocol version
	ProtoVersion message.ProtocolVersion
}

Config of connection

type OnProcess

type OnProcess struct {
	// Publish call when PUBLISH message received
	Publish func(msg *message.PublishMessage) error

	// Ack call when PUBACK/PUBREC/PUBREL/PUBCOMP received
	Ack func(msg message.Provider) error

	// Subscribe call when SUBSCRIBE message received
	Subscribe func(msg *message.SubscribeMessage) error

	// UnSubscribe call when UNSUBSCRIBE message received
	UnSubscribe func(msg *message.UnSubscribeMessage) (*message.UnSubAckMessage, error)

	// Disconnect call when connection falls into error or received DISCONNECT message
	Disconnect func(will bool)
}

OnProcess callbacks to parent session

type Provider

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

Provider implementation of the connection

func New

func New(config *Config) (conn *Provider, err error)

New connection

func (*Provider) Start

func (s *Provider) Start()

Start serving messages over this connection

func (*Provider) Stop

func (s *Provider) Stop()

Stop connection. Effective is only first invoke

func (*Provider) WriteMessage

func (s *Provider) WriteMessage(msg message.Provider) (int, error)

WriteMessage writes a message to the outgoing buffer

Jump to

Keyboard shortcuts

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