Hi! I'm adding loading popups and error messages to my game - not only to let users know when something goes wrong, but so things can be a bit more clear to me during development when I don't have a console log easily available.
In my game, I'm calling LobbyService.CreateLobby
to create (and as I understand, join) a lobby. I also have a callback registered via RTTService.RegisterRTTLobbyCallback
to handle the various lobby operation
types.
At the moment I'm a bit stumped on when the best time to show and hide a loading spinner is.
My current setup is this:
- Show loading spinner ("Creating lobby...")
CreateLobby
and wait for Success- Hide loading spinner
- Wait for "STARTING"
operation
from Lobby <- (problem is here because this takes a second or two) - Show loading spinner ("Joining lobby...")
- Wait for "ROOM_READY" or "DISBANDED"
operation
- Hide loading spinner
This results in a loading spinner that appears briefly for "Creating lobby...", then no spinner for a slightly longer gap while we wait to get the first operation
back from the server, and then a "Joining lobby..." spinner until joining the room succeeds or fails.
I'm not sure exactly how to treat that gap. I could just omit the "Hide" after the lobby is successfully created, but am I guaranteed in all cases to get some sort of response (even a timeout) from the server, or does that create a risk of a hanging loading spinner that never goes away? Is there some sort of state dispatched from the BrainCloudWrapper that neatly surrounds "The user wants to join a lobby", and "The user has succeeded/failed in joining that lobby"?
NOTE: One maybe-important caveat is that I'm setting this up without an actual running server to connect to at the moment - primarily because I want to make sure that in such a case where the client can't reach the server, it gracefully informs the player and allows them to try again.