javascript - What does callback(false) and callback(true) do? -


i'm studying example project of nodejs chat, , can't understand happens when callback(false) , callback(true) called here...

io.sockets.on('connection', function(socket){     socket.on('new user', function(data, callback){         if(usernames.indexof(data) != -1){             callback(false);         } else {             callback(true);             socket.username = data;             usernames.push(socket.username);             updateusernames();         }     }); 

callback acknowledgement function

server

        socket.on('new user',            function(data, calback){                   // incidentally(not needed in case) send data value true                    calback(true);           }          ); 

client

    socket.emit('new user',                data,                function(confirmation){                        console.log(confirmation);                       //value of confirmation == true if call callback(true)                       //value of confirmation == false if call callback(false)                }              ); 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -