Looking for some help with Switchboard session management

Hello! I’m currently stuck on this issue:

Let’s say someone hits you up on Messenger. You receive the RNG command and start a new Switchboard connection.

However, once you idle for a bit, you or the other person will disconnect, sending the BYE command. But then, if they want to talk to you again, they’ll send you another RNG.

Right now, I have a switchboardSessions variable which is an object (map) that holds another object with the key being the Switchboard session ID. I also have the Switchboard gateway session ID (because I’m using the HTTP gateway). Example:

add to switchboardSessions...:
parts[1]: {
              gatewayId: gatewaySessionId,
              sessionId: parts[1],
              server: parts[2],
              authKey: parts[4],
              email: parts[5],
              nick: parts[6]

I also have a messages object, which uses the Switchboard session ID (not gateway). Example:

messages: {
        sessionId: [
            from: '(user email)',
            text: 'HI',
            time: new Date()

The issue would be when they talk to you, the session ID is different. How should I tackle managing this? That is, how would I know what switchboard session was the original?

Another issue would be group conversations… :frowning:

Note: this is MSNP8.