2015-07-22 16:28:15 +00:00
|
|
|
"use strict";
|
|
|
|
|
2015-07-29 13:50:39 +00:00
|
|
|
var fs = require("fs");
|
|
|
|
var path = require("path");
|
2015-09-05 16:26:39 +00:00
|
|
|
var winston = require("winston");
|
2015-08-10 23:12:27 +00:00
|
|
|
var client = require(path.join(__dirname, "../ensl/client"))();
|
|
|
|
const mapsPath = path.join(__dirname, "../../config/data/maps.json");
|
|
|
|
const REFRESH_INTERVAL = 1000 * 60 * 60; // Check every hour
|
2015-07-22 16:28:15 +00:00
|
|
|
|
|
|
|
function Map () {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-08-10 23:12:27 +00:00
|
|
|
Map.list = JSON.parse(fs.readFileSync(mapsPath)).maps;
|
|
|
|
|
|
|
|
Map.updateMapList = () => {
|
|
|
|
client.getMaps((error, result) => {
|
|
|
|
if (error) {
|
|
|
|
winston.error("Unable to download server list")
|
|
|
|
winston.error(error);
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
Map.list = result.maps;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
Map.updateMapList();
|
|
|
|
|
|
|
|
setInterval(Map.updateMapList, REFRESH_INTERVAL);
|
2015-07-29 13:50:39 +00:00
|
|
|
|
|
|
|
module.exports = Map;
|