onStatusUpdated Doesnt invoke when reconnect from network disconnection

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

  • 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?

  • 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
    Tobias admin

    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.