Clean up abandoned matches and fix analytics validation
This commit is contained in:
@@ -12,7 +12,7 @@ export function registerPresence(io: Server, sessions: GameSessionStore) {
|
||||
}
|
||||
namespace.use((socket, next) => {
|
||||
const { gameSessionId, token } = socket.handshake.auth;
|
||||
void sessions.get({ gameSessionId, token }).then(session => {
|
||||
void sessions.touchPresence({ gameSessionId, token }).then(session => {
|
||||
socket.data.playerId = session.playerId ?? session.gameSessionId;
|
||||
next();
|
||||
}, error => next(new Error(error instanceof ApiError && error.statusCode === 401 ? 'INVALID_SESSION' : 'PRESENCE_UNAVAILABLE')));
|
||||
@@ -25,7 +25,7 @@ export function registerPresence(io: Server, sessions: GameSessionStore) {
|
||||
if (checking) return;
|
||||
checking = true;
|
||||
const { gameSessionId, token } = socket.handshake.auth;
|
||||
void sessions.get({ gameSessionId, token }).catch(error => {
|
||||
void sessions.touchPresence({ gameSessionId, token }).catch(error => {
|
||||
if (error instanceof ApiError && error.statusCode === 401) socket.disconnect(true);
|
||||
else socket.conn.close(); // Transport closure permits Socket.IO to reconnect after a transient outage.
|
||||
}).finally(() => { checking = false; });
|
||||
|
||||
Reference in New Issue
Block a user