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.GenericPacket, error)
- func (s *MemorySession) AllSubscriptions() ([]*packet.Subscription, error)
- func (s *MemorySession) ClearWill() error
- func (s *MemorySession) DeletePacket(dir Direction, id packet.ID) error
- func (s *MemorySession) DeleteSubscription(topic string) error
- func (s *MemorySession) LookupPacket(dir Direction, id packet.ID) (packet.GenericPacket, error)
- func (s *MemorySession) LookupSubscription(topic string) (*packet.Subscription, error)
- func (s *MemorySession) LookupWill() (*packet.Message, error)
- func (s *MemorySession) NextID() packet.ID
- func (s *MemorySession) Reset() error
- func (s *MemorySession) SavePacket(dir Direction, pkt packet.GenericPacket) error
- func (s *MemorySession) SaveSubscription(sub *packet.Subscription) error
- func (s *MemorySession) SaveWill(newWill *packet.Message) 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.
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.
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 (*PacketStore) All ¶ added in v0.5.0
func (s *PacketStore) All() []packet.GenericPacket
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.GenericPacket
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.GenericPacket)
Save will store a packet in the store. An eventual existing packet with the same id gets quietly overwritten.