Added basic serverside command logic (no commands yet)
This commit is contained in:
parent
358d01d730
commit
4c1f0f10a7
3 changed files with 58 additions and 3 deletions
|
|
@ -18,23 +18,29 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const validator = require('validator');//No express here, so regular validator it is!
|
||||
|
||||
//local imports
|
||||
const commandPreprocessor = require('./commandPreprocessor');
|
||||
const loggerUtils = require('../../utils/loggerUtils');
|
||||
const {userModel} = require('../../schemas/userSchema');
|
||||
|
||||
module.exports = class{
|
||||
constructor(server){
|
||||
this.server = server;
|
||||
this.commandPreprocessor = new commandPreprocessor(server)
|
||||
}
|
||||
|
||||
defineListeners(socket){
|
||||
socket.on("chatMessage", (data) => {this.relayChat(socket, data)});
|
||||
socket.on("chatMessage", (data) => {this.handleChat(socket, data)});
|
||||
socket.on("setFlair", (data) => {this.setFlair(socket, data)});
|
||||
socket.on("setHighLevel", (data) => {this.setHighLevel(socket, data)});
|
||||
}
|
||||
|
||||
handleChat(socket, data){
|
||||
this.commandPreprocessor.preprocess(socket, data);
|
||||
}
|
||||
|
||||
relayChat(socket, data){
|
||||
//Trim and Sanatize for XSS
|
||||
const msg = validator.trim(validator.escape(data.msg));
|
||||
const msg = validator.trim(validator.escape(data));
|
||||
const user = this.server.getSocketInfo(socket);
|
||||
|
||||
//nuke the message if its empty or huge
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue