Disconnecting from Chat not flushing friends list

First off I am using the PUN with v1.89 showing in the changelog.

When my client quits the app they will disconnect from chat. According to the remarks for RemoveFriends it says...
/// Photon flushes friends-list when a chat client disconnects. Unless you want to
/// remove individual entries, you don't have to RemoveFriends.

However, I am not finding this to be true. When I restart the app and log back in the friends list is still on the servers. As soon as I log in I get a status update from my friends, even before I have added them back. This throws my status out of sync as the status update is received before I can setup my friends.

It works fine to begin with as friends are not sent using AddFreinds until their respective friend profile panel is setup.

Would this work correctly if I manually disconnected instead of disconnecting with the OnApplicationQuit callback?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Teddymac,

    I could not reproduce this issue.
    Could you share with us minimal repro steps?
    How do you disconnect?
    instead of disconnecting with the OnApplicationQuit callback?
    What do you mean? A disconnect is a disconnect...
  • Today I've tried to reproduce it myself but it's been working correctly. I only have one place that adds friends list and yesterday I turned that off and I was still getting status updates from a friend.

    I had Unity running on my PC and an Android test device with the friend in question logged in to Chat. I never logged them out during my testing. As soon as my PC logged in it would get a friend status update from the Android before I ever added the friends to the chat list with chatClient.AddFriends. After the called to AddFriends it would get another status update so the status update was being called once by the server itself (it would seem) and once by my code.

    I added code to compensate for this that would not update my friend objects until the chatClient.AddFriends was called and this prevented the thrown exception. I will turn that error check off and if it happens again I'll get an exception and report back.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited August 2018
    It could be that you are using the same UserId on both devices?
    If that's the case then all connected clients with the same UserId will receive the same messages.
    One connected client is enough to keep the same 'server context' for all by persisting channels subscriptions, status and friends list.
  • I use unique names for each user with PlayFab ids and both devices have its own account so that isn't the current case.

    I seen this happen once again yesterday while testing, but I was testing the remove, add, invite friend functionality and after removing the friend this didn't happen again. And its not happening now either.

    OnApplicationQuit is where I disconnect from chat. Perhaps somehow the signal isn't being sent to disconnect the player after I stop the editor from playing.

    Ok, while typing this I just started the editor while the Android version is logged in and this issue is happening again. As soon as I connect to chat it gives me a status update of my friends. Which at that point I have not added any friends so this should not happen.

    I just removed the AddFriends code where I am not even adding friends and I still get an immediate status update of my Android friend as soon as I log into chat.

    I've been testing all morning, but just now I restarted the PC Unity Editor in play mode 3 times within say 3 min, and the third time I have this issue.

    So, maybe I'm logging back into chat before the friends list is flushed? Well, I waited over 4 min before the next log in and I still get the friends status update. Which the android friend is just idling at the main menu.
    Or, the signal that I logged out isn't being sent? That is the only thing that seems reasonable at the moment. I will test this by manually logging out of chat.... Nope, even when manually disconnecting I still get this issue. I got the OnDisconnected callback so I know I was disconnected. But when I quit the app and restart in playmode I once again get the friend status update. The friend's name on Android is ValiantJoker and the Unity user is fredcardshark. I need to quite testing for a while, but will be back later.

    And so, I have no idea why this is happening.
  • Could it be that the since the Android version ValiantJoker has fredcardshark as a friend, that when fredcardshark logs into chat, ValiantJoker instantly sends him a status update?