I'm handling over 15 different socket events, I'd like to manage certain socket.io events within the modules that are related to those events.
For example, I'd like to have a file named login.js handle the login
socket event, and a file named register.js handle the registration socket event.
index.js:
socket.on(connection, function (client) {
console.log(Client connected to socket!);
client.on(login, function (data) {
validate(data){
socket.sockets.emit(login_success, data);
}
});
client.on(register, function (data) {
register(data){
socket.sockets.emit(register_success, data);
}
});
});
Is there a way that I can put client.on(register, function (data) { ...
in one file and client.on(login, function (data) { ...
in another?