[4.10.1] IOnlineFriendsPtr Read and Get return false

I’m trying to retrieve a steam friend list from a logged in user, but I keep getting false for both the ReadFriendsList() and GetFriendsList()

    auto OnlineSub = IOnlineSubsystem::Get();

	//Make sure it exists
	if (OnlineSub != nullptr)
	{
		auto userFriendsPtr = OnlineSub->GetFriendsInterface();
		auto userIdentityPtr = OnlineSub->GetIdentityInterface();

		if (!userFriendsPtr.IsValid())
		{
			friendNames.Add(" Invalid Friend Ptr ");
			return false;
		}

		if (!userIdentityPtr.IsValid())
		{
			friendNames.Add(" Invalid Identity Ptr ");
			return false;
		}

		friendNames.Add(FString::Printf(TEXT(" Login Status: %s "), ELoginStatus::ToString(userIdentityPtr->GetLoginStatus(localUserID))));

		friendNames.Add(userIdentityPtr->GetPlayerNickname(localUserID));

		if (userFriendsPtr->ReadFriendsList(localUserID, EFriendsLists::ToString(EFriendsLists::Default)))
		{
			friendNames.Add(" FriendList not found ");
		}
     }

The above will output:

Friend:  Login Status: LoggedIn 
Friend: AlliedGames Multiplayer Test Acc
Friend: FriendList not found 

So, it knows I am logged in, it knows who I am, but it cannot retrieve my friend list. This is using the STEAM OnlineSubsystem.

Tracing through the code it looks like one of the following checks is failing, but I’m not sure which (I don’t have the engine source and the breakpoints don’t seem to do anything in OnlineFriendsInterfaceSteam.cpp)

LocalUserNum < MAX_LOCAL_PLAYERS &&
	SteamUserPtr != NULL &&
	SteamUserPtr->BLoggedOn() &&
	SteamFriendsPtr != NULL

I’m using the default steam SDK that 4.10.1 comes with, if that makes a difference.

There are only a few cases that cause that to fail: invalid list name, no logged in player, or the SteamFriends() call returned null. The call back is sent the reason of the error. I see you aren’t registering for it, so that is hurting your ability to debug what is going on

Hey Joe,

Thanks a lot for your reply, I completely forgot about the delegate, turns out ReadFriendList() is not the problem, it returns true. Implementing the delegate confirms that it finished successfully without an errorMessage.

OnReadFriendListComplete LocalUserNum: 0 bSuccess: 1 FriendList: default Error: 

Now

if (!userFriendsPtr->GetFriendsList(localUserID, EFriendsLists::ToString(EFriendsLists::Default), myFriendList))
		{ friendNames.Add(FString::Printf(TEXT(" FriendList get returns false "))); }

GetFriendsList() seems to be the problem as it returns false. I’m thinking FriendsLists.Find() returns null in OnlineFriendsInterfaceSteam.cpp

FSteamFriendsList* FriendsList = FriendsLists.Find(LocalUserNum);

Any suggestion on where a possible error could be found that could indicate why FriendsLists.Find() would be null?

The only way I see that being null is if you call that function before the read completes. The finalize of the read unconditionally adds the local user to that map, so there will be one even if their list is empty. Best thing is to step through the code and see what’s going wrong there for you

I realize my mistake now, thanks Joe!

I was indeed calling the function before the read had a chance to complete, thanks for clearing that up.