beyond-all-reason / bar-lobby

BAR Lobby Client
https://beyond-all-reason.github.io/bar-lobby/
MIT License
33 stars 30 forks source link

Host battle sometimes doesn't work #193

Open Jazcash opened 1 year ago

Jazcash commented 1 year ago

image

Sometimes the host battle dialog gets stuck. This is an issue in SPADS, supposedly related to unitsync: https://discord.com/channels/549281623154229250/564591092360675328/1094023521224630332

We can mitigate this problem on the lobby side by requesting !privatehost from the least utilised clusters. Currently it's hardcoded to always ask the first cluster in the array of userIds for each region in HostBattle.vue.

As we're on the battle list view when this modal is open, we can be sure that api.sessions.battles exists and is updated, so we can iterate through this and collect infomation about how many instances belong to each cluster based on the bot usernames (we might have to do an additional request here to get the usernames for each bot from its userId).

Using this info, we should also be able to know which clusters exist, because I believe clusters always have at least 1 empty battle open. Once we know how many instances belong to each cluster, we can request a private host from the cluster in the desired region with the least amount of active instances.