diff options
Diffstat (limited to 'src/renderer/gameserver')
-rw-r--r-- | src/renderer/gameserver/data.ts | 2 | ||||
-rw-r--r-- | src/renderer/gameserver/onlineCount.ts | 6 |
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)=>{ |