I want to check the online status of friends when I connect the first time with Photon. The other player can't find me online. But after playing one match, when I rejoin the lobby it finds me online and on the Master server. What's the problem? The Code is given Below.
//LOBBY JOINING CODE
void Awake()
{
Instance = this;
//PhotonNetwork.Disconnect();
}
void Start()
{
PhotonNetwork.Disconnect();
if (!PhotonNetwork.IsConnected)
{
Debug.Log("Connecting to Master");
PhotonNetwork.ConnectUsingSettings();
//PhotonNetwork.AutomaticallySyncScene = true;
}
else if (!PhotonNetwork.InLobby && !PhotonNetwork.IsConnected)
{
PhotonNetwork.JoinLobby();
PhotonNetwork.AutomaticallySyncScene = true;
}
if (RoomManager.Instance == null)
{
Instantiate(roomManager);
}
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected to Master");
PhotonNetwork.JoinLobby();
PhotonNetwork.AutomaticallySyncScene = true;
}
public override void OnJoinedLobby()
{
Debug.Log("The Server used is : "+PhotonNetwork.Server);
PhotonNetwork.AuthValues = new AuthenticationValues();
PhotonNetwork.AuthValues.UserId =PlayerData.userName;
MenuManager.Instance.OpenMenu("title");
Debug.Log("Joined Lobby");
}
//Find Friend Code
public void InviteFriend()
{
PhotonNetwork.FindFriends(new string[] { "Hammas"});
}
public override void OnFriendListUpdate(List<FriendInfo> friendsInfo)
{
for (int i = 0; i < friendsInfo.Count; i++)
{
FriendInfo friend = friendsInfo[i];
Debug.LogFormat("{0}", friend);
}
}
This is in the main scene. But the match is on the other scene. When I come back to the main scene from the match, then it works fine. Please describe the reason why it's happening.
I try to reconnect to lobby without matchmaking but still error exits. But when I join lobby after matchmaking then it works fine.