onStatusUpdated Doesnt invoke when reconnect from network disconnection

Options
I have friend Online system using photon chat. before disconnection everything works fine users get their friends online state properly, but after after disconnection I reconnect with chat after that I use add friend method to invoke on status update, but I doesnt get invoked.. its frustrating..... Here is the code
Connect And Disconnect code
 private void ConnectToPhotonChat(string nickName)
    {
        chatClient.Connect(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat, PhotonNetwork.AppVersion, new Photon.Chat.AuthenticationValues(nickName));
    }

    public void DisconnectFromPhotonChat()
    {
        chatClient.Disconnect();
    }

Add friend method
 private IEnumerator FindPhotonFriends()
        {
        
            if (chatClient == null) yield break;

            while (chatClient.State != ChatState.ConnectedToFrontEnd)
            {
               yield return new WaitForSeconds(0.3f);
            }

            if (friendList.Count == 0)
            {
               noFriendsText.gameObject.SetActive(true);
            }
            if (friendList.Count != 0)
            {
                noFriendsText.gameObject.SetActive(false);
                initialized = true;
                string[] friendDisplayNames = friendList.ToArray();                
                chatClient.AddFriends(friendDisplayNames);
                print(friendDisplayNames[0]);
            }
            OnDisplayFriends?.Invoke(friendList);
        }


Answers

  • Andrey
    Options
    Hey Yuvi,
    Please post more details regarding your issue:

    You are calling disconnect() and then connect() without restarting your app, right?
    Are you doing this kind of instantly - disconnect()->w8 for confirmation->connect() or there is a pause between this actions?

  • Yuvi
    Options

    I will call connect when i open my game.... And when i turn off device's network connection... And turn it on my status becomes offline in other devices.. how should i implement this.... This issue is frustrating me... Kindly please help

  • Tobias
    Options

    You need to learn how to debug these situations or you will be stuck most of the time.

    I would put in several lines of Debug.Log() into all the code to verify it really runs in the first place. Check your variables (make sure friends are sent to the server again), etc.

    It's near impossible to help with such things without having a look at the full project.

  • Yuvi
    Options

    Bro, I am explaining you my situation clearly.....

    First I am try to connect with photon and photon chat with same user ID, it connects and i can see other user online or offline status. While watching a advertisement, it disconnects photon and photon chat... Disconnection is not my problem. I try to reconnect with photon and photon chat after watching ad. It connects but this time it only shows other users as offline even through they are online. And in other user's device it shows me as offline. First connection works properly but when i try to reconnect after some disconnection it doesnt work properly... I add some debug statement to find what is happening. I found that in reconnection, when i try to call chatClient.addFriend method.... It not send me user status on userStatusUpdated function. Please help me to fix this issue.

  • Andrey
    Options

    Please contact us by email developer@photonengine.com and provide us with your appid so we can check our logs. Also please check that you are setting your user online after reconnect, that's may be the case too.

    Thanks.