Updated callbacks to all return
This commit is contained in:
@@ -20,7 +20,7 @@ async function getPresetsOfOnlineNodes(callback) {
|
|||||||
systems[onlineNode.id] = utils.BufferToJson(onlineNode.nearbySystems);
|
systems[onlineNode.id] = utils.BufferToJson(onlineNode.nearbySystems);
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(systems);
|
return callback(systems);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ async function requestNodeListenToPreset(preset, nodeId, callback) {
|
|||||||
"channelID": discordConfig.channelID,
|
"channelID": discordConfig.channelID,
|
||||||
"presetName": preset
|
"presetName": preset
|
||||||
}), (responseObject) => {
|
}), (responseObject) => {
|
||||||
callback(responseObject)
|
return callback(responseObject)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ async function getNodeBotStatus(nodeId, callback) {
|
|||||||
else {
|
else {
|
||||||
// Bot is free
|
// Bot is free
|
||||||
}
|
}
|
||||||
callback(responseObject);
|
return callback(responseObject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -58,13 +58,13 @@ async function requestNodeLeaveServer(nodeId, callback) {
|
|||||||
mysqlHandler.getNodeInfoFromId(nodeId, (nodeObject) =>{
|
mysqlHandler.getNodeInfoFromId(nodeId, (nodeObject) =>{
|
||||||
reqOptions = new requests.requestOptions("/bot/leave", "POST", nodeObject.ip, nodeObject.port);
|
reqOptions = new requests.requestOptions("/bot/leave", "POST", nodeObject.ip, nodeObject.port);
|
||||||
requests.sendHttpRequest(reqOptions, JSON.stringify({}), (responseObject) => {
|
requests.sendHttpRequest(reqOptions, JSON.stringify({}), (responseObject) => {
|
||||||
callback(responseObject);
|
return callback(responseObject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Bot is free
|
// Bot is free
|
||||||
callback(false);
|
return callback(false);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ exports.sendHttpRequest = function sendHttpRequest(requestOptions, data, callbac
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.DEBUG("Response Object: ", responseObject);
|
log.DEBUG("Response Object: ", responseObject);
|
||||||
callback(responseObject);
|
return callback(responseObject);
|
||||||
})
|
})
|
||||||
}).on('error', err => {
|
}).on('error', err => {
|
||||||
log.ERROR('Error: ', err.message)
|
log.ERROR('Error: ', err.message)
|
||||||
@@ -58,7 +58,7 @@ exports.sendHttpRequest = function sendHttpRequest(requestOptions, data, callbac
|
|||||||
|
|
||||||
if (requestOptions.timeout) {
|
if (requestOptions.timeout) {
|
||||||
req.setTimeout(requestOptions.timeout, () => {
|
req.setTimeout(requestOptions.timeout, () => {
|
||||||
callback(false);
|
return callback(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ connection.connect()
|
|||||||
exports.getAllNodes = (callback) => {
|
exports.getAllNodes = (callback) => {
|
||||||
const sqlQuery = `SELECT * FROM ${nodesTable}`
|
const sqlQuery = `SELECT * FROM ${nodesTable}`
|
||||||
runSQL(sqlQuery, (rows) => {
|
runSQL(sqlQuery, (rows) => {
|
||||||
callback(rows);
|
return callback(rows);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ exports.getAllNodes = (callback) => {
|
|||||||
exports.getOnlineNodes = (callback) => {
|
exports.getOnlineNodes = (callback) => {
|
||||||
const sqlQuery = `SELECT * FROM ${nodesTable} WHERE online = 1;`
|
const sqlQuery = `SELECT * FROM ${nodesTable} WHERE online = 1;`
|
||||||
runSQL(sqlQuery, (rows) => {
|
runSQL(sqlQuery, (rows) => {
|
||||||
callback(rows);
|
return callback(rows);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ exports.getNodeInfoFromId = (nodeId, callback) => {
|
|||||||
runSQL(sqlQuery, (rows) => {
|
runSQL(sqlQuery, (rows) => {
|
||||||
// Call back the first (and theoretically only) row
|
// Call back the first (and theoretically only) row
|
||||||
// Specify 0 so downstream functions don't have to worry about it
|
// Specify 0 so downstream functions don't have to worry about it
|
||||||
callback(rows[0]);
|
return callback(rows[0]);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ exports.addNewNode = (nodeObject, callback) => {
|
|||||||
const sqlQuery = `INSERT INTO ${nodesTable} (name, ip, port, location, nearbySystems, online) VALUES ('${name}', '${ip}', ${port}, '${location}', '${nearbySystems}', ${online})`;
|
const sqlQuery = `INSERT INTO ${nodesTable} (name, ip, port, location, nearbySystems, online) VALUES ('${name}', '${ip}', ${port}, '${location}', '${nearbySystems}', ${online})`;
|
||||||
|
|
||||||
runSQL(sqlQuery, (rows) => {
|
runSQL(sqlQuery, (rows) => {
|
||||||
callback(rows);
|
return callback(rows);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ exports.updateNodeInfo = (nodeObject, callback) => {
|
|||||||
sqlQuery = `${sqlQuery} WHERE id = ${nodeObject.id};`
|
sqlQuery = `${sqlQuery} WHERE id = ${nodeObject.id};`
|
||||||
|
|
||||||
runSQL(sqlQuery, (rows) => {
|
runSQL(sqlQuery, (rows) => {
|
||||||
if (rows.affectedRows === 1) callback(true);
|
if (rows.affectedRows === 1) return callback(true);
|
||||||
else callback(rows);
|
else return callback(rows);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user