-
Notifications
You must be signed in to change notification settings - Fork 15
lab-dana #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
lab-dana #11
Conversation
… in net module and confirmed server starting up.
… if no command given.
…converted all functions to arrow.
const command = data.toString().split(' ').shift().trim(); | ||
const msg = data.toString().split(' ').slice(1).join(' '); | ||
|
||
if(command.includes('@all')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have a lot of repeated code here. You could probably D.R.Y. this out and use just one conditional.
if(command.startsWith('@')) {
ee.emit(command, client, data.toString().split(' ').slice(1).join(' '));
return;
}
JavaScript allows this, you can pass any arbitrary number of arguments to a function so you don't necessarily need to create a different conditional statement to handle each command.
///+++++ server events +++++\\\ | ||
|
||
server.on('connection', (socket) => { | ||
ee.emit('login', socket); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awesome way of handling the connection
. I like how you modularized your code here and separated out your server events into additional code blocks.
No description provided.