Hide a room from being found using findfriends

Options
My users have friend lists and are able to use the photon findfriends method to find other players and join the room they are currently inside. My users can also create a hidden room BUT it seems I am unable to hide this room from findfriends. I tried setting publishuserid to false in the room options but the room name is still found and the room can be joined. How can I make it so that if a user sets their room as visible = false that it cannot be found by findfriends and therefore joined by unwanted players. My users want the ability to hide the room from public or hide the room from public and friends. Currently I can only hide it from the public as find friends always find s the room whether it is visible or not.

Best Answers

  • Ash68
    Ash68
    edited March 2017 Answer ✓
    Options
    OK I found a way through this. I used PhotonNetwork.AuthValues to set a fake/unkown userid when connecting, then after connecting I change the playername to be the real playername. This then has me connected under one fake userid but playing as far as other players are concerned under my real userid. Findfriends fails to find me. I then have an option to switch from 'hidden' mode back to normal mode and this happens with a photon disconnect and then a reconnect using the AuthValues set to my real userid .... now I can be found with find friends again. I need to test if this causes any other weird problems but on an quick initial test it appears to be ok.

Answers

  • Ash68
    Ash68
    edited March 2017
    Options
    I've even tried setting the photonnetwork.player.Userid to an arbitrary value before joining the network and it still finds the correct user and marks them as online when I do a findfriends. What do you have to do to make this thing not work? The documentation seems to indicate the Userid field is the key to how findfriends works but this just doesn't appear to be the case as I can still find a friend when this value is set to garbage.
  • Ash68
    Options
    So I changed the playername and now findfriends doesn't find the player ..... I can probably work with that but it's not exactly the ideal solution to my original problem.
  • Ash68
    Options
    No this doesn't work either as even if I disconnect from the network and then reconnect with a different player name it still finds the player with the original name (before I changed it) in findfriends. Only if I completely exit the application and restart can I get it to forget the playername. Which leads me to another question which is how do you reset the network so that on reconnect it recognises the new player as a different player as the name has changed.
  • Ash68
    Ash68
    edited March 2017 Answer ✓
    Options
    OK I found a way through this. I used PhotonNetwork.AuthValues to set a fake/unkown userid when connecting, then after connecting I change the playername to be the real playername. This then has me connected under one fake userid but playing as far as other players are concerned under my real userid. Findfriends fails to find me. I then have an option to switch from 'hidden' mode back to normal mode and this happens with a photon disconnect and then a reconnect using the AuthValues set to my real userid .... now I can be found with find friends again. I need to test if this causes any other weird problems but on an quick initial test it appears to be ok.
  • Ash68
    Ash68
    edited March 2017
    Options
    Thanks for answering, fortunately I don't use the userid for authentication activity, so I can 'bend' the way it works to my needs.
    The problem arose because some users wanted to be able to run truly private off the grid rooms/sessions and they couldn't do it as people who were friends could always find them and the hidden room and then join.
    So I think it's a valid request for functionality, I understand the need for it, it just took a bit of lateral thinking to get to the solution with how Photon friend functionality works now.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Did you consider closing rooms (room.IsOpen = false) or reserving slots for players (ExpectedUsers) to prevent unwanted ones from joining?
    Otherwise you could add some keyword to room names for players that want to be hidden.
    When you create rooms for players who want to be hidden, you add that string to the room name.
    If the room name is returned by FindFriends, check for that string, if it's there then no need to show the room name for friends.
    If the player who creates the room want it to be visible to friends but the one who joins does not you can make use of room custom properties or special lobby to matchmake only players that have desire the same visibility to friends.
    Of course this means you can't change things once the room is created unlike your workaround.
  • Ash68
    Options
    It's a bit of a complex issue this as some users requested that they have the ability to just hide entirely, so friends wouldn't know they were online or in a room, so it stretched a bit wider than just room only behavior, although this was the main focus. If it was just room join then the options you suggested would all be reasonable approaches. I think of it a bit like how skype works, you have people you are connected with who can see when you are online/active but if you want to appear as being offline then you can - that's all it effectively is.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hey @Ash68,

    ICYMI: I just want to mention that we offer the feature you are asking for in Photon Chat.
    You can set an Online Status just like Skype with an optional message.
    Maybe you can consider that.