Skip to content

Add a second call to ReadFriendsList() #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

arousta
Copy link

@arousta arousta commented Dec 27, 2023

Observe that after the second call the GetFriends() won't return the list of friends.

The bug is here in the FUserManagerEOS::AddFriend() function:

	// Add this friend as a remote player if we haven't already (this will grab user info)
	if (!UniqueNetIdToAttributeAccessMap.Contains(FriendNetId))
	{
		AddRemotePlayer(LocalUserNum, EpicAccountId, FriendRef);
	}

The UniqueNetIdToAttributeAccessMap basically contains the cached information of friends which is populated during the first call to the ReadFriendsList().

During the second call, here we skip calling the AddRemotePlayer() function to avoid making unnecessary requests for obtainig the friends info which we already have in our cache.

However the problem is that we've forgotten to set the friend info using our cached values in the else block. The fix would be to move a piece of code from the FUserManagerEOS::ReadUserInfo() to here:

	// Add this friend as a remote player if we haven't already (this will grab user info)
	if (!UniqueNetIdToAttributeAccessMap.Contains(FriendNetId))
	{
		AddRemotePlayer(LocalUserNum, EpicAccountId, FriendRef);
	}
        else
        {
        // set user info from the cached info
            IAttributeAccessInterfaceRef AttributeAccessRef = UniqueNetIdToAttributeAccessMap[FriendNetId];
            FOnlineFriendEOSPtr FriendPtr = LocalUser.FriendsList->GetByNetId(FriendNetId);
            FriendPtr->UpdateInternalAttributes(AttributeAccessRef->GetInternalAttributes());
        }

Observe that after the second call the GetFriends() won't return the list of friends
@arousta arousta closed this Dec 27, 2023
@arousta arousta deleted the ReadFriendsList-second-call-issue branch December 27, 2023 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant