Browse Source

undefined msg fix

Ivan Asmer 4 years ago
parent
commit
64790813f6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      index.js

+ 1 - 1
index.js

@@ -12,7 +12,7 @@ app.get('/', function(req, res){
 io.on('connection', function(socket){
   console.log('an user connected with id', socket.id);
   socket.on('msg', function(msg){
-      if (msg.message && msg.nick){
+      if (msg && msg.message && msg.nick){
           io.emit('msg', msg)
       }
       else {