Open PatriQ94 opened 4 years ago
Okay so upon further testing of this function I can confidently say that it doesn't work properly when a summoner leaves a match.
Here's the code that I used https://pastebin.com/eCPQzsFB How its supposted to work: It checks every 5 seconds if a player entered a match, prints outs a message, then keeps checking until the player left the match, then prints a message.
How it behaves: It prints out a message when user entered a match, but when player leaves a match, the GetCurrentGameAsync sometimes throws an exception, sometimes it returns data of an already ended match and it's doing so for a few minutes after the player already left the match.
Is this issue based on RiotApi or RiotSharp?
Is this issue based on RiotApi or RiotSharp?
RiotApi is a class within RiotSharp, so not sure exactly what you're asking. There's the exact code so you can check it out.
It's a question of whether this is an issue with Riot Game's API (https://developer.riotgames.com/) or RiotSharp. The API returns a 404 when the summoner is not in the game, so RiotSharp throws an error for that (I believe). (It doesn't necessarily have to behave this way).
If you're getting data back after a match ended, that is going to be 100% on Riot's API end. RiotSharp just handles requests to the API and returns whatever the API gave back.
It's a question of whether this is an issue with Riot Game's API (https://developer.riotgames.com/) or RiotSharp. The API returns a 404 when the summoner is not in the game, so RiotSharp throws an error for that (I believe). (It doesn't necessarily have to behave this way).
I see, yeah makes sense. It's unfortunate that it throws error with "404 - Data not found" tho instead of simply returning null.
If you're getting data back after a match ended, that is going to be 100% on Riot's API end. RiotSharp just handles requests to the API and returns whatever the API gave back.
I'll do some more testing and contact Riot then.
I'm fairly sure, that returning a 404 error is the intended behavior, when the summoner isn't in a game.
One could argue 404 is null in http
I would argue 204 is more like null than 404 is, but Riot's API doesn't give 204s unfortunately
Okay so I've contacted Riot and asked about this issue - why is their endpoint /lol/spectator/v4/active-games/by-summoner/{encryptedSummonerId}
API returning random data (sometimes old data, sometimes an 404 exception). Keep in mind that this endpoint is connected to the problem I'm having with function GetCurrentGameAsync
. So it looks like their distributed systems don't update caches fast enough and when I'm calling GetCurrentGameAsync
I hit different servers, therefore getting random answers. They have also suggested to not call it more than once per minute or so, so their caches get updated.
Why does
await api.Spectator.GetCurrentGameAsync
throw an exception if the player is not in a game? It should either return the correctCurrentGame
with populated data or return null.