session

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package session implements session objects to be used with MQTT clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction int

Direction denotes a packets direction.

const (
	// Incoming packets are being received.
	Incoming Direction = iota

	// Outgoing packets are being be sent.
	Outgoing
)

type MemorySession

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

A MemorySession stores packets in memory.

func NewMemorySession

func NewMemorySession() *MemorySession

NewMemorySession returns a new MemorySession.

func (*MemorySession) AllPackets

func (s *MemorySession) AllPackets(dir Direction) ([]packet.GenericPacket, error)

AllPackets will return all packets currently saved in the session.

func (*MemorySession) AllSubscriptions

func (s *MemorySession) AllSubscriptions() ([]*packet.Subscription, error)

AllSubscriptions will return all subscriptions currently saved in the session.

func (*MemorySession) ClearWill

func (s *MemorySession) ClearWill() error

ClearWill will remove the will message from the store.

func (*MemorySession) DeletePacket

func (s *MemorySession) DeletePacket(dir Direction, id packet.ID) error

DeletePacket will remove a packet from the session. The method must not return an error if no packet with the specified id does exists.

func (*MemorySession) DeleteSubscription

func (s *MemorySession) DeleteSubscription(topic string) error

DeleteSubscription will remove the subscription from the session. The method will not return an error if no subscription with the specified topic does exist.

func (*MemorySession) LookupPacket

func (s *MemorySession) LookupPacket(dir Direction, id packet.ID) (packet.GenericPacket, error)

LookupPacket will retrieve a packet from the session using a packet id.

func (*MemorySession) LookupSubscription

func (s *MemorySession) LookupSubscription(topic string) (*packet.Subscription, error)

LookupSubscription will match a topic against the stored subscriptions and eventually return the first found subscription.

func (*MemorySession) LookupWill

func (s *MemorySession) LookupWill() (*packet.Message, error)

LookupWill will retrieve the will message.

func (*MemorySession) NextID

func (s *MemorySession) NextID() packet.ID

NextID will return the next id for outgoing packets.

func (*MemorySession) Reset

func (s *MemorySession) Reset() error

Reset will completely reset the session.

func (*MemorySession) SavePacket

func (s *MemorySession) SavePacket(dir Direction, pkt packet.GenericPacket) error

SavePacket will store a packet in the session. An eventual existing packet with the same id gets quietly overwritten.

func (*MemorySession) SaveSubscription

func (s *MemorySession) SaveSubscription(sub *packet.Subscription) error

SaveSubscription will store the subscription in the session. An eventual subscription with the same topic gets quietly overwritten.

func (*MemorySession) SaveWill

func (s *MemorySession) SaveWill(newWill *packet.Message) error

SaveWill will store the will message.

Jump to

Keyboard shortcuts

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