I am consuming a game API that updates all active player statistics in real time in the game.
I'm trying to make a way for my code to listen to this API (outside of a loop) and when there are changes in your json response, my code will print on the console. I'm currently trying with Ruby Events, but I didn't get anything other than out of a loop (while true
).
old_data = ""
while true
sleep 1
data = Utils.req("GET", "https://127.0.0.1:2999/liveclientdata/playerscores?summonerName=Yoruku", {}, false)
#{"assists":0,"creepScore":50,"deaths":0,"kills":5,"wardScore":0}
next if data.eql? old_data
old_data = data
p "NEW DATA: #{data}"
end