The previous implementation handled expiry incorrectly and was very confusing to think about. This version is much simpler and seems more obviously correct. The only remaining question is that of race conditions related to the time between you "having" a session ID (socket connection) and "knowing about" the session ID (channel join), and we're pretending those don't matter for now.
For simplicity, we now make no effort to reuse the session ID between reconnects, reflecting the reality that session IDs are not currently intended to actually be reliably reused by a user over time.
Note that the store of session IDs belonging to the bot is global, which actually seems "more correct" in the case that you have multiple ReticulumClient objects hanging around -- you would prefer the bot not to respond to messages from other copies of itself. It would be better for it to persist, because then the bot would know about its old session IDs if it restarted and rejoined the same Hubs room. When we implement a persistent data store it should probably go in there.
Also clean up logging to be more helpful and create log entries on reconnects.
The previous implementation handled expiry incorrectly and was very confusing to think about. This version is much simpler and seems more obviously correct. The only remaining question is that of race conditions related to the time between you "having" a session ID (socket connection) and "knowing about" the session ID (channel join), and we're pretending those don't matter for now.
For simplicity, we now make no effort to reuse the session ID between reconnects, reflecting the reality that session IDs are not currently intended to actually be reliably reused by a user over time.
Note that the store of session IDs belonging to the bot is global, which actually seems "more correct" in the case that you have multiple
ReticulumClient
objects hanging around -- you would prefer the bot not to respond to messages from other copies of itself. It would be better for it to persist, because then the bot would know about its old session IDs if it restarted and rejoined the same Hubs room. When we implement a persistent data store it should probably go in there.Also clean up logging to be more helpful and create log entries on reconnects.