Skip to content

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

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Conversation

dkulp23
Copy link

@dkulp23 dkulp23 commented Feb 21, 2017

No description provided.

const command = data.toString().split(' ').shift().trim();
const msg = data.toString().split(' ').slice(1).join(' ');

if(command.includes('@all')) {

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);

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants