Clean up token mapping when client disconnects. Args: token: The client token. sid: The Socket.IO session ID.
(self, token: str, sid: str)
| 335 | return new_token |
| 336 | |
| 337 | async def disconnect_token(self, token: str, sid: str) -> None: |
| 338 | """Clean up token mapping when client disconnects. |
| 339 | |
| 340 | Args: |
| 341 | token: The client token. |
| 342 | sid: The Socket.IO session ID. |
| 343 | """ |
| 344 | # Only clean up if we own it locally (fast ownership check) |
| 345 | if ( |
| 346 | (socket_record := self.token_to_socket.get(token)) is not None |
| 347 | and socket_record.sid == sid |
| 348 | and socket_record.instance_id == self.instance_id |
| 349 | ): |
| 350 | # Clean up Redis |
| 351 | redis_key = self._get_redis_key(token) |
| 352 | try: |
| 353 | await self.redis.delete(redis_key) |
| 354 | except Exception as e: |
| 355 | console.error(f"Redis error deleting token: {e}") |
| 356 | |
| 357 | # Clean up local dicts (always do this) |
| 358 | await super().disconnect_token(token, sid) |
| 359 | |
| 360 | @staticmethod |
| 361 | def _get_lost_and_found_key(instance_id: str) -> str: |
nothing calls this directly
no test coverage detected