• Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums

[Unity] LobbyService.CreateLobby - Best time to show and hide a "Connecting..." popup?

Scheduled Pinned Locked Moved Solved APIs
3 Posts 2 Posters 67 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PJ
    wrote last edited by
    #1

    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.

    1 Reply Last reply
    0
  • J Offline
    J Offline
    JasonL bitHeads
    wrote last edited by
    #2

    First, it's recommended to use FindOrCreateLobby call instead of CreateLobby. It’s generally a better approach since it handles both cases — creating a new lobby if one doesn’t exist, or joining an existing one if it does. This gives your players a smoother experience when first trying to get into a lobby.

    Second, just to clarify the sequence: the STARTING event doesn’t mean the lobby itself is starting, it happens after members have already joined and the server launch conditions are met. At that point, brainCloud is spinning up a game server for the lobby. You can find more details in our lobby documentation here -- https://docs.braincloudservers.com/api/capi/lobby/#lobby-events

    Because of this, your loading spinner should remain active continuously after the FindOrCreateLobby call succeeds, since the user’s intent (“joining a lobby”) isn’t complete yet, from the user’s perspective, they’re still “joining a lobby” until they either:

    Receive ROOM_READY → success, hide the spinner.

    Receive an error → failure, hide the spinner and show an error.

    This way, you avoid the hide → show gap, and the spinner matches the full lifecycle of the join process; it simply stays up until the full lobby join flow is resolved.

    So in short: use FindOrCreateLobby, and keep the loading spinner up until you get either ROOM_READY or a failure event.

    1 Reply Last reply
    1
  • P PJ has marked this topic as solved
  • P Offline
    P Offline
    PJ
    wrote last edited by
    #3

    Apologies for the late reply, but thank you! This really clears up the flow for me. 🙂

    The only thing regarding FindOrCreateLobby instead of CreateLobby is that the request to CreateLobby is deliberate. While I do intend to integrate FindOrCreateLobby as a "just throw me into a running game" option (which probably is the desired flow in most cases), I also want a player to be able to say "I want to start a game for my friends, and I also want to be the host and set the rules of the room".

    I'm just clarifying that in case I'm misunderstanding the intent between the two calls, and that FindOrCreateLobby can indeed be used for either flow that I just described.

    1 Reply Last reply
    0

  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users