summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawnCable <lawncable.tmw2@simonlaux.de>2018-06-30 19:37:08 +0200
committerLawnCable <lawncable.tmw2@simonlaux.de>2018-06-30 19:37:08 +0200
commita810ecff525f6cf49381c47c1072b2799bc0b7d5 (patch)
tree84bdf9cffae9edf712afe876662593d23af34ef6
parentf0b4b484b13371fe842966ee7ad687f39011d1ab (diff)
downloadelectron-a810ecff525f6cf49381c47c1072b2799bc0b7d5.tar.gz
electron-a810ecff525f6cf49381c47c1072b2799bc0b7d5.tar.bz2
electron-a810ecff525f6cf49381c47c1072b2799bc0b7d5.tar.xz
electron-a810ecff525f6cf49381c47c1072b2799bc0b7d5.zip
online list for tmw2onlineCount
-rw-r--r--src/renderer/gameserver/data.ts2
-rw-r--r--src/renderer/gameserver/onlineCount.ts6
2 files changed, 7 insertions, 1 deletions
diff --git a/src/renderer/gameserver/data.ts b/src/renderer/gameserver/data.ts
index a55b745..eb0f74f 100644
--- a/src/renderer/gameserver/data.ts
+++ b/src/renderer/gameserver/data.ts
@@ -31,7 +31,7 @@ const TMW2 = new GameServer(
new socialLink("fab fa-gitlab","Gitlab","https://gitlab.com/TMW2"),
],
"https://tmw2.org/legal",
- {parser:OnlineListParser.EXAMPLE_DATA,url:"example"}
+ {parser:OnlineListParser.JSON_ARRAY,url:"https://tmw2.org/online.json"}
);
const Evol = new GameServer(
diff --git a/src/renderer/gameserver/onlineCount.ts b/src/renderer/gameserver/onlineCount.ts
index d78fa96..cfde7e5 100644
--- a/src/renderer/gameserver/onlineCount.ts
+++ b/src/renderer/gameserver/onlineCount.ts
@@ -56,6 +56,7 @@ export enum OnlineListParser {
TMW,
TMW2API,
EXAMPLE_DATA,
+ JSON_ARRAY
};
async function fetchOnlineList(server:GameServer):Promise<string[]>{
@@ -74,6 +75,8 @@ async function fetchOnlineList(server:GameServer):Promise<string[]>{
];
case OnlineListParser.TMW:
return tmwParser(await request(server.OnlineList.url));
+ case OnlineListParser.JSON_ARRAY:
+ return jsonArrayParser(await request(server.OnlineList.url));
default:
throw new Error("Online List Parser is unknown");
}
@@ -92,6 +95,9 @@ function tmwParser(rawData:string):string[]{
return stringArray;
}
+function jsonArrayParser(rawData:string):string[]{
+ return JSON.parse(rawData);
+}
function request(url:string):Promise<string>{
return new Promise((res, rej)=>{