Callback for updates to room's ExpectedUsers?

Options
I am trying to display the Expected Users list (PhotonNetwork.room.expectedUsers) in the UI of players already inside the room. The idea is that if a group of players want to join a room, the UI can show who has joined the room and who hasn't yet.

As far as I can tell, there is no callback defined for when the Expected Users list changes while connected to a room. The callback OnReceivedRoomListUpdate() is only called while in a lobby, I believe.

If this is true, should I use SetRoomCustomProperties to write the userIds to the room before joining it? This seems worse than relying on Photon to handle it, since I do not know if JoinRoom() will succeed.

Best Answer

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @warreneng,

    If this is true, should I use SetRoomCustomProperties to write the userIds to the room before joining it?

    No you just need to use "Publish UserIDs" feature as explained here.

    Clients should be notified with ExpectedUsers changes in properties change event. You can get it from PhotonNetwork.OnEventCall.
    Maybe this needs a callback in PUN.
  • Hi,

    It's funny, I was excactly thinking about this a few minutes ago.

    I am currently working on new UI elements for PUN typical interfaces needs ( room list, player list, etc), and my next steps was to handle expected users inside a room. So let me check on this, and if indeed there is a missing feature on getting an update for expected users, I'll submit a ticket for consideration for the next releases of pun, because indeed I think it should be there.

    Bye,

    Jean
  • Hi,

    ok, so I confirm that to catch room expectedUsers update, you need to watch for Room properties update, since ExpectedUsers are saved inside Room Properties. So that's how you are getting notified that expectedUsers may have changed.

    I would keep a cached version of expectedUsers and on Room Properties change callback, I would compare it if you need to know who got added as a user joined the room with new expectedUsers or if the list was cleared using Room.ClearExpectedUsers()

    one other way, if to check room expectedUsers everytime a player joins, that would also work.

    Bye,

    Jean
  • warreneng
    Options
    Hi Jean, follow-up questions:

    When an expected player arrives in a room, does Photon remove that player from the room's expected players list? Or does Photon only add to that list over time until I call room.ClearExpectedUsers()? Is there any way I can clear just that player from the list?
  • warreneng
    Options
    That'll work perfectly. Thank you very much for you help!