mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-15 03:02:17 -05:00
here goes nothin'
This commit is contained in:
@@ -10,6 +10,8 @@ function normalizeRoverId(value) {
|
||||
}
|
||||
|
||||
function buildRequesterKey(socket) {
|
||||
const userId = String(socket?.data?.userId || '').trim();
|
||||
if (userId) return `user:${userId}`;
|
||||
const cookieUserId = normalizeCookieUserId(socket?.data?.cookieUserId);
|
||||
if (cookieUserId) return `cookie:${cookieUserId}`;
|
||||
return `socket:${socket?.id || 'unknown'}`;
|
||||
@@ -44,6 +46,14 @@ function getSocketByRequesterKey(requesterKey) {
|
||||
const socketId = requesterKey.slice('socket:'.length);
|
||||
return io.sockets.sockets.get(socketId) || null;
|
||||
}
|
||||
if (requesterKey.startsWith('user:')) {
|
||||
const userId = requesterKey.slice('user:'.length);
|
||||
for (const socket of io.sockets.sockets.values()) {
|
||||
if (String(socket?.data?.userId || '').trim() === userId) {
|
||||
return socket;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requesterKey.startsWith('cookie:')) {
|
||||
const cookieUserId = requesterKey.slice('cookie:'.length);
|
||||
for (const socket of io.sockets.sockets.values()) {
|
||||
|
||||
Reference in New Issue
Block a user