subscriber

package
Version: v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2018 License: Apache-2.0 Imports: 7 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 {
	ID             string
	OfflinePublish Publisher
	Topics         topicsTypes.SubscriberInterface
	Version        packet.ProtocolVersion
}

Config subscriber config options

type Publisher added in v0.0.4

type Publisher interface {
	Publish(string, *packet.Publish)
}

type SessionProvider added in v0.0.4

type SessionProvider interface {
	Subscriptions() Subscriptions
	Subscribe(string, *topicsTypes.SubscriptionParams) (packet.QosType, []*packet.Publish, error)
	UnSubscribe(string) error
	HasSubscriptions() bool
	Online(c Publisher)
	Offline(bool)
	Hash() uintptr
}

SessionProvider passed to present network connection

type Subscriptions

type Subscriptions map[string]*topicsTypes.SubscriptionParams

Subscriptions contains active subscriptions with respective subscription parameters

type Type

type Type struct {
	Config
	// contains filtered or unexported fields
}

Type subscriber object

func New

func New(c Config) *Type

New allocate new subscriber

func (*Type) Acquire

func (s *Type) Acquire()

Acquire prevent subscriber being deleted before active writes finished

func (*Type) GetID added in v0.0.4

func (s *Type) GetID() string

GetID get subscriber id

func (*Type) GetVersion added in v0.0.4

func (s *Type) GetVersion() packet.ProtocolVersion

GetVersion return MQTT protocol version

func (*Type) HasSubscriptions

func (s *Type) HasSubscriptions() bool

HasSubscriptions either has active subscriptions or not

func (*Type) Hash

func (s *Type) Hash() uintptr

Hash returns address of the provider struct. Used by topics provider as a key to subscriber object

func (*Type) Offline

func (s *Type) Offline(shutdown bool)

Offline put session offline if shutdown is true it does unsubscribe from all active subscriptions

func (*Type) Online

func (s *Type) Online(c Publisher)

Online moves subscriber to online state since this moment all of publishes are forwarded to provided callback

func (*Type) Publish

func (s *Type) Publish(p *packet.Publish, grantedQoS packet.QosType, ops packet.SubscriptionOptions, ids []uint32) error

Publish message accordingly to subscriber state online: forward message to session offline: persist message

func (*Type) Release

func (s *Type) Release()

Release subscriber once topics provider finished write

func (*Type) Subscribe

func (s *Type) Subscribe(topic string, params *topicsTypes.SubscriptionParams) (packet.QosType, []*packet.Publish, error)

Subscribe to given topic

func (*Type) Subscriptions

func (s *Type) Subscriptions() Subscriptions

Subscriptions list active subscriptions

func (*Type) UnSubscribe

func (s *Type) UnSubscribe(topic string) error

UnSubscribe from given topic

Source Files

Jump to

Keyboard shortcuts

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