Hello everyone, I'm having trouble with getting around asynchronous model of node, I have this function
function getstream() {
console.log('calling testAvail, Avail value is:' + available);
testAvailability();
console.log('Available:'+available);
if (available || SelfSharing) {
// Do something
setDefaults();
return;
}
function testAvailability()
{
console.log('entered test');
var stat;
socket.on('error', function() {
console.log('There was an error at server end please try again');
// chrome.runtime.reload();
setTimeout(chrome.runtime.reload(),3000);
//here i change options
//socket = io.connect(host, options);
});
socket.emit('available');
socket.on('available', function (status) {
console.log('got status from server which is:'+ status);
available=status;
console.log("inside the socket.on"+available);
console.log('leaving test, do you see any got status above?');
});
}