Room disconnect grace period

Reference for the files delivered in Main_File. Documentation updated 22 September 2026. Examples use fictional IDs and balances; replace them with values from your installation.

Socket disconnect timer

Explicit leaveRoom runs immediately with its original behavior. If a user disconnects from Socket.IO while still in a room, Node stores a Redis job with uid, rid and a deadline 60 seconds later. PHP enterMember, used by startLive and enterRoom, cancels only the event for the same user and room. Socket reauthentication alone does not cancel it. Entering another room keeps the old room's timer, and each room has an independent event. Disconnects after an explicit socket room leave do not create a job.

When the minute expires, Node removes the timer and sends POST /api/live/leaveRoomByServer (alias /api/liva/leaveRoomByServer) with JSON {"uid":42,"rid":7} and headers X-Server-Secret and X-API-KEY. No user token is required. PHP checks the password and runs the original leaveRoom behavior for the supplied user and room, preserving the user's new room mapping if they entered another room.

Set the identical ROOM_DISCONNECT_SECRET in PHP .env and Node .env. Generate it with node -e "console.log(require('crypto').randomBytes(32).toString('hex'))". Node loads its own environment file. Set Node PHP_API_URL to the PHP base URL before /api and restart Node after deploying the PHP and Node changes. Keep this value on the server.

The socket disconnect's original presence cleanup and the application's existing room-entry flow are unchanged. Redis stores pending timers in app:disconnect:jobs and their deadlines in app:disconnect:due.