jeremyckahn / farmhand

A resource management game that puts a farm in your hand
https://www.farmhand.life
GNU General Public License v2.0
100 stars 25 forks source link

feat(multiplayer): Optimize API usage #494

Closed jeremyckahn closed 5 months ago

jeremyckahn commented 5 months ago

What this PR does

This PR optimizes multiplayer API usage by eliminating polling. Rather than using the Vercel-based central API to determine room occupancy, the number of connected peers is used.

How this change can be validated

:bangbang: Please DO NOT test this in the default global room, as that affects Production data. Instead, use another room such as global-test.

Additional information

This change is needed because Farmhand is getting so much multiplayer activity that we're exceeding the capacity of the free Vercel tier that is powering it.

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
farmhand ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 30, 2024 2:22am
jeremyckahn commented 5 months ago

~It looks like this PR can't be validated in the Preview Environment because of CORS domain restrictions. It can only really be tested on my machine because I can't give access to the Vercel environment without paying for the Pro tier. So, we'll just have to settle for a code review of this PR.~

EDIT: This has been fixed by setting the REACT_APP_API_ROOT environment variable to /. I'm noticing an issue in which the player cannot disconnect properly in the Preview Deployment, so I will need to get that fixed before merging this.

jeremyckahn commented 5 months ago

I'm noticing an issue in which the player cannot disconnect properly in the Preview Deployment, so I will need to get that fixed before merging this.

This should be fixed with the latest changes! This is ready for review.