Skip to content

Commit

Permalink
Merge pull request #57 from KATITB22/task/load-testing
Browse files Browse the repository at this point in the history
chore: bypass auth for load testing
  • Loading branch information
rafirm29 authored Aug 17, 2022
2 parents 510ed96 + 57a2adf commit 167ee90
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/socket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ function socket({
}) {
console.log('🖥️ Sockets enabled');

io.use(authMiddleware.authSocketMiddleware);
// TODO: Uncomment after testing
// io.use(authMiddleware.authSocketMiddleware);

io.use(async (socket, next) => {
const isLoggedIn = await sessionServices.checkSession(socket.data.username);
console.log(`Status ${socket.data.username}: ${isLoggedIn}`);
if (isLoggedIn) {
next(new Error('Already Logged In! Please disconnect your other tab(s)'));
}
// io.use(async (socket, next) => {
// const isLoggedIn = await sessionServices.checkSession(socket.data.username);
// console.log(`Status ${socket.data.username}: ${isLoggedIn}`);
// if (isLoggedIn) {
// next(new Error('Already Logged In! Please disconnect your other tab(s)'));
// }

next();
});
// next();
// });

io.on('connection', async socket => {
// TODO: Remove mock data
socket.data.name = socket.handshake.auth.name;
socket.data.username = socket.handshake.auth.username;
// usersManager.addUser();
// io.emit('onlineUsers', usersManager.numUsers);
console.log(`🟩 User connected ${socket.data.username} (${socket.id})`);
Expand Down

0 comments on commit 167ee90

Please sign in to comment.