Search Unity

Question Joining game with custom data

Discussion in 'Lobby' started by erdmannjacob0, Mar 14, 2023.

  1. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    Hey all,

    I need to send custom player data each time a player joins such as inventory and stats, It looks like I get a size error when I try to send larger inventories, looks like it can only accept 1024 bytes of data. Any ideas for sending full inventories and player stats to get setup from lobby service to game server?
     
  2. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    The lobby service is not intended to be used to transfer large volumes of data that could likely go out of date. An alternative solution would really depend on your use case. What do you need the inventory and stats data for? Does every member of the lobby need access to the data or is it just the host?

    Lobbies are _mostly_ intended to be used to enable players to find each other and get the information that they need to connect. The basic example we always show is to create a Lobby that contains Relay connection details. Other players can search/browse/join a Lobby and then use the connection details to create a direct connection with the other players. In you case, after this Relay connection (or maybe a P2P connection with the host) is established, the game client can send the larger amount of data directly to the host.

    As a general rule, the data being stored in a Lobby should be something that is relevant for other searching or browsing for lobbies. This is not a hard requirement though. If you can help us understand your use case, we can see if maybe there's a scenario we're missing and whether it makes sense to loosen the restrictions a bit.
     
  3. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    no problem, the current system uses lobby as intended for the most part, just as a place for players to congregate and join a pregame, in the lobby they also use the economy system to stores items from previous games and buy more items for future games/equip items to their character, then using matchmaker they can connect to a server authoritative game. The problem is that they need to be able to bring the items they equipped in the lobby to their character into the game. Storing that information in lobby isn't great but I haven't seen an alternative to where I am supposed to pass that info.
     
  4. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    Hmmm.... let me discuss this with the team and see what they think. Do you have an estimate for the approximate size of the data you need?

    The limits that we have right now are (mostly) arbitrary in order to protect you from a malicous user who might be sending huge amounts of data in a Lobby which could result in excessive charges to your account since Lobby is billed based on bandwidth. We could consider exposing a configuration setting to allow you to increase the limits for a specific project to allow your scenario.
     
  5. erdmannjacob0

    erdmannjacob0

    Joined:
    Nov 23, 2021
    Posts:
    16
    I don't really have a goal size yet, a slider would be nice, I am just sending strings in json format right now, so I can try to serialize them in a better format and maybe save some space there, I can only send like 4 or 5 game items as of right now and they aren't very complex items. So, I guess preferably it needs to be several times larger. I am not sure what that would look like cost wise though.