Open Asaayu opened 3 years ago
Possible fix could be creating a web client application specifically for the web socket, allowing the application to continue to sync but through the web client web socket rather then through web API requests.
I haven't tried anything with web clients or web sockets for the extension, but hopefully there will be a way of doing it that does not require an extra window to be open in the background, require double authorization, or crash the game in the process.
Had a go at trying to find and connect to a web socket. Had a bit of trouble and didn't really get a good way working, main issue was having the web socket connection running while also getting around issues and limitations with extensions in Arma 3.
I've given some web sockets a go and it seems like the Web Playback sockets only ping back data when the web player is the active device. That means there is very little that I can do to avoid rate limiting when getting user data.
My best idea at the moment is to have a 5 second delay when the GUI is open, and then double it to 10 seconds when the GUI is closed. That way the notifications can still appear somewhat quickly, but the actual GUI updating will be as real-time as possible without limiting the total number of users.
Due to limitations in the Spotify API there may be cases where the application is rate limited.
Main issue I can see is the syncing between the Spotify client and the mod. Due to the issue of having to update when a song changes outside of Arma 3 the sync needs to be called even when the GUI isn't open. This means a player playing for an hour will call (3600/x) requests to the API, where x is the wait in seconds between calls. Graph for reference
Due to the exponential increase of requests, the difference between a 9 second wait and a 8 second wait is 50 requests. Whereas the difference between a 3 second wait and a 4 second wait is 300 requests.
Another thing to consider is that this is a per-user total. So the number of requests an hour is then multiplied by the number of users. Current implementation is a 5 second wait between requests which is 720 requests per hour. Which would mean a mod with 200 concurrent users would have 144,000 requests per hour. But should the mod have a large influx of concurrent users then the API will be hit with 1m requests at only 1390 concurrent users. Graph for reference
From reading around on the Spotify Github and developer forums I've found the following,
This is an ongoing issue and based on past experience from other developers probably won't be fixable at all.