session

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2019 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Overview

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

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 IDCounter added in v0.5.0

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

An IDCounter continuously counts packet ids.

func NewIDCounter added in v0.5.0

func NewIDCounter() *IDCounter

NewIDCounter returns a new counter.

func NewIDCounterWithNext added in v0.10.0

func NewIDCounterWithNext(next packet.ID) *IDCounter

NewIDCounterWithNext returns a new counter that will emit the specified if id as the next id.

func (*IDCounter) NextID added in v0.5.0

func (c *IDCounter) NextID() packet.ID

NextID will return the next id.

func (*IDCounter) Reset added in v0.5.0

func (c *IDCounter) Reset()

Reset will reset the counter.

type MemorySession

type MemorySession struct {
	Counter  *IDCounter
	Incoming *PacketStore
	Outgoing *PacketStore
}

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.Generic, error)

AllPackets will return all packets currently saved in the session.

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) LookupPacket

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

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

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.Generic) error

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

type PacketStore added in v0.5.0

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

PacketStore is a goroutine safe packet store.

func NewPacketStore added in v0.5.0

func NewPacketStore() *PacketStore

NewPacketStore returns a new PacketStore.

func NewPacketStoreWithPackets added in v0.10.0

func NewPacketStoreWithPackets(packets []packet.Generic) *PacketStore

NewPacketStoreWithPackets returns a new PacketStore with the provided packets.

func (*PacketStore) All added in v0.5.0

func (s *PacketStore) All() []packet.Generic

All will return all packets currently saved in the store.

func (*PacketStore) Delete added in v0.5.0

func (s *PacketStore) Delete(id packet.ID)

Delete will remove a packet from the store.

func (*PacketStore) Lookup added in v0.5.0

func (s *PacketStore) Lookup(id packet.ID) packet.Generic

Lookup will retrieve a packet from the store.

func (*PacketStore) Reset added in v0.5.0

func (s *PacketStore) Reset()

Reset will reset the store.

func (*PacketStore) Save added in v0.5.0

func (s *PacketStore) Save(pkt packet.Generic)

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

Jump to

Keyboard shortcuts

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