Skip to content

Commit 1dfd3d6

Browse files
committed
Use sockets namespaces
1 parent 7e105f3 commit 1dfd3d6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

middlewares/socketio.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { JWT_SECRET } = require('../config');
33

44
const { sendMessage } = require('../controllers/messages');
55

6+
// Socket.IO Middleware for Auth
67
function socketAuth(socket, next) {
78
const { token } = socket.handshake.query;
89

@@ -22,7 +23,10 @@ function socketAuth(socket, next) {
2223
function socketio(io) {
2324
io.use(socketAuth);
2425

25-
io.on('connection', (socket) => {
26+
const v1 = io.of('/v1');
27+
28+
// TODO: Move this sockets handlers somewhere
29+
v1.on('connection', (socket) => {
2630
socket.on('mount-chat', (chatId) => {
2731
socket.join(chatId);
2832
});

0 commit comments

Comments
 (0)