user.some(function(value) {
CreateRoomHash(userID, value._id, function (err, roomhash) {
if(err) console.log(err);
if(roomhash) {
console.log("ROOMHASH:" + roomhash);
retrieveRoom(roomhash, function(err, room) {
if(err) console.log(err);
if(room) {
console.log("ROOM FOUND: " + room);
if(room.status) {
console.log("Existing room found:"+ roomsha);
JoinRoom(roomsha);
response.json({Roomhash: roomsha});
return true;
} else {
console.log("ROOM STATUS IS FALSE");
return false;
}
} else {
console.log("ROOM NOT FOUND");
var newRoom = CreateRoom(roomsha, userID, matchedID);
console.log("No existing room found, new room created:" + roomsha);
response.json({Roomhash: newRoom});
return true;
}
});
console.log("COOL:"+cool)
}
console.log("COOL:"+cool)
});
});
});
初学者。我有两个嵌套的回调函数,CreateRoomHash和retrive Room。如何为我的回调函数返回true或false,这样我可以打破我的some()?