Answer the question
In order to leave comments, you need to log in
How to move socket routing to a separate file?
io.on('connection', (socket) => {
socket.on('INVENTORY_CONNECT', (data) => {
socket.join(data);
});
socket.on('disconnect', (data) => {
console.log('CLIENT DISCONECT');
});
socket.on('DRAG', (data) => {
const { inventoryID, HTML_ID_ELEMENT,coords} = data;
let msg = { HTML_ID_ELEMENT,coords };
socket.broadcast.to(inventoryID).emit('CLEAR', msg);
});
socket.on('UNDO', (data) => {
const { userInventoryId, Coords, activeElem } = data;
let msg = {
Coords,
activeElem
};
socket.broadcast.to(userInventoryId).emit('UNDO', msg);
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question