minimq
minimq copied to clipboard
Refactor session state message storage
Currently, messages with QoS > AtMostOnce are stored in the SessionState. MQTT requires that we republish these messages upon reconnection with the broker in the same order as originally published.
Currently, we store the messages in two datastructures. One is a vector of message IDs (in order) and the other is a map of the messages (where the ID is the key to the map).
It would be desirable to combine these into a single datastructure. Some requirements:
- Removing an element must not result in large copies, as this may result in copying far too much memory if there's a lot of pending messages
- A single data structure should be used
- An ideal implementation may allow us to not hold any additional buffer space (e.g. when QoS AtMostOnce is used exclusively).