* Attach a new WebSocket to an existing session. * Cancels any running grace timer. * Returns null if the session does not exist.
(token: string, ws: WebSocket)
| 76 | * Returns null if the session does not exist. |
| 77 | */ |
| 78 | reattach(token: string, ws: WebSocket): StoredSession | null { |
| 79 | const session = this.sessions.get(token); |
| 80 | if (!session) return null; |
| 81 | |
| 82 | if (session.graceTimer) { |
| 83 | clearTimeout(session.graceTimer); |
| 84 | session.graceTimer = null; |
| 85 | } |
| 86 | session.ws = ws; |
| 87 | session.lastActive = new Date(); |
| 88 | return session; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Detach the WebSocket from a session and start the grace period timer. |