Documentation ¶
Overview ¶
Package session implements session objects to be used with MQTT clients and brokers.
Index ¶
- type Direction
- type IDCounter
- type MemorySession
- func (s *MemorySession) AllPackets(dir Direction) ([]packet.Generic, error)
- func (s *MemorySession) DeletePacket(dir Direction, id packet.ID) error
- func (s *MemorySession) LookupPacket(dir Direction, id packet.ID) (packet.Generic, error)
- func (s *MemorySession) NextID() packet.ID
- func (s *MemorySession) Reset() error
- func (s *MemorySession) SavePacket(dir Direction, pkt packet.Generic) error
- type PacketStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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
NewIDCounterWithNext returns a new counter that will emit the specified if id as the next id.
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 ¶
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.