Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Brite
  • 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
  1. Home
  2. Cloud Code
  3. Lobby creation/deletion events in CloudCode

Lobby creation/deletion events in CloudCode

Scheduled Pinned Locked Moved Unsolved Cloud Code
13 Posts 3 Posters 4.4k Views 3 Watching
  • 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.
  • A Offline
    A Offline
    Alessio Falsetti
    wrote on last edited by
    #4

    Yes Paul, exactly. There is a lobby browser and I would like to avoid polling it. I currently poll using lobbyProxy.getLobbyInstances to get the list, but then I have to loop through the list and get the settings/extra json with lobbyProxy.getLobbyData. However, all this is very expensive (1 API call getLobbyInstance and 1 API call for each getLobbyData). Having the created/deleted events would be ideal, alternatively if getLobbyInstances also returned the lobby settings it could also be an acceptable alternative.
    There is also another problem: since the update is timed, closed lobbies are still visible to users in the browser, and this also creates a bit of confusion because at that point users have to be told that that lobby no longer exists if they click on it.

    Greg, by connected users, I mean the users who are currently playing and are connected via RTT, regardless of whether they are in the lobby or not. It would be useful to have the possibility of sending a broadcast message to all players online at that moment or to a subset of users with some filter (e.g. he is playing a match, exclude him from the list).

    Suggestions? 🙂

    Thanks!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Alessio Falsetti
      wrote on last edited by
      #5

      Greg, I just saw that you introduced SysSendEventToProfiles in version 5.0. Something like that but without needing to specify the list of users 🙂

      1 Reply Last reply
      0
      • Greg MouldsG Offline
        Greg MouldsG Offline
        Greg Moulds
        brainCloudAdmin
        wrote on last edited by
        #6

        Thanks for the additional details Alessio. Paul and I will discuss some options and get back to you.

        1 Reply Last reply
        0
        • Greg MouldsG Offline
          Greg MouldsG Offline
          Greg Moulds
          brainCloudAdmin
          wrote on last edited by Greg Moulds
          #7

          Hey Alessio. I just thought of something that might help you with part of your use-case. We do have the facility for you to attach some arbitrary data to a lobby instance that WILL be returned in the GET_LOBBY_INSTANCES
          call. That piece of data is set by specifying a "_public" key in the lobby instance "settings" field. For example, here's a sample call to create a lobby instance that sets it:

          CREATE_LOBBY REQUEST:

          {
             "service": "lobby",
             "operation": "CREATE_LOBBY",
             "data": {
                "lobbyType": "TestPVP",
                "rating": 76,
                "otherUserCxIds": [],
                "settings": {
                   "_public": {
                      "hello": "world"
                   }
                },
                "isReady": false,
                "extraJson": {},
                "teamCode": "all"
          }
          }
          

          CREATE_LOBBY RESPONSE:

          {
             "status": 200,
             "data": {
                "lobbyId": "23713:TestPVP:41"
             }
          }
          

          GET_LOBBY_INSTANCES REQUEST:

          {
             "service": "lobby",
             "operation": "GET_LOBBY_INSTANCES",
             "data": {
                "lobbyType": "TestPVP",
                "criteriaJson": {
                   "rating": {
                      "min": 25,
                      "max": 99
                   }
                }
             }
          }
          

          GET_LOBBY_INSTANCES RESPONSE:

          {
             "status": 200,
             "data": {
                "lobbiesByRating": {
                   "76.0": [{
                      "id": "23713:TestPVP:41",
                      "lobbyType": "TestPVP",
                      "state": "early",
                      "rating": 76,
                      "desc": "TestPVP",
                      "owner": {
                         "profileId": "c14caf2b-6c72-4c8e-9280-54356f7d56c2",
                         "name": "",
                         "rating": 0,
                         "cxId": "23713:c14caf2b-6c72-4c8e-9280-54356f7d56c2:nscnrabmi1ukk1ncr2dqpf9nau"
                      },
                      "numMembers": 1,
                      "maxMembers": 2,
                      "publicSettings": {
                         "hello": "world"
                      }
                   }]
                }
             },
          }
          
          1 Reply Last reply
          0
          • Greg MouldsG Offline
            Greg MouldsG Offline
            Greg Moulds
            brainCloudAdmin
            wrote on last edited by
            #8

            Notice that the "_public" settings key/value is returned as a "publicSettings" key/value in the response to GET_LOBBY_INSTANCES. Is that something that you can take advantage of for your use-case?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Alessio Falsetti
              wrote on last edited by
              #9

              Ciao Greg,

              yes this thing would be great, it would be perfect for what I need!

              I'm currently trying this solution, please tell me if you think there might be any problems:

              1. when a user enters in the view with the lobby browser I invoke a script on the BC side in which I save the user's profileId in a Global Entity. When the user leave the browser view, I invoke the same service that removes him.
              2. when a user creates a lobby, I develop an API Hook which at the CreateLobby event (post) takes the IDs saved in the list and with SysSendEventToProfiles informs the users to update the lobby list
              3. when a user leaves, with the LeaveLobby Hook API (post), I check if the lobby has been removed, if so, as per point 2, I inform the users to update the list

              The change you suggest would be an excellent further optimization and would be fantastic 😉

              My doubts now are these:

              1. although the number of users in the list saved in Global Enity is less than 1000 (average 400 users), do you think there could be performance problems?
              2. if the app crash or closed unexpectedly, the user list in the Global Entity may not be updated because the removal event does not arrive at BC, at that point if SysSendEventToProfiles sends to non-connected profileIds, what happens? I have to try and find a way to clean the list.

              Suggestions?

              Thank you!

              Alessio

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Alessio Falsetti
                wrote on last edited by
                #10

                Ciao!

                With the procedure described above and the modification you made for the publicSettings I think I have solved the problem of having to do polling. All I have to do is figure out how to clean the list of profileIds in the Global Entity in case of an unexpected crash.
                Thanks guys for the support! If you have any other suggestions, they are welcome 🙂

                1 Reply Last reply
                0
                • Greg MouldsG Offline
                  Greg MouldsG Offline
                  Greg Moulds
                  brainCloudAdmin
                  wrote on last edited by
                  #11

                  Great to hear Alessio. Let us know if anything else pops up or if you notice any other gaps. Ciao!

                  1 Reply Last reply
                  0
                  • Greg MouldsG Offline
                    Greg MouldsG Offline
                    Greg Moulds
                    brainCloudAdmin
                    wrote on last edited by
                    #12

                    I'll let Paul speak to the performance issues that you mention as concerns. I think your right to be concerned about that performance so I'll let Paul chime in.

                    1 Reply Last reply
                    0
                    • Paul WinterhalderP Offline
                      Paul WinterhalderP Offline
                      Paul Winterhalder
                      brainCloudAdmin
                      wrote on last edited by
                      #13

                      Hi Alessio,

                      I have a suggestion.

                      Why not create a global chat channel called "lobbyListeners".

                      Then - when a user is viewing the lobbies - have them connect to and listen to the lobbyListeners channel.

                      Then you don't need to maintain a global entity at all. Whenever you create a lobby or delete it - send an event to lobbyListeners - and it will automatically send it to everyone who has registered for the channel.

                      Would that work? (or is there a part of your use case that I am missing?)

                      Paul.

                      1 Reply Last reply
                      0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

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