Skip to content

Friends

Francisco Dias edited this page Jun 20, 2024 · 5 revisions

Friends

Playing games with your friends and meeting new players online are important parts of many online services. The Epic Online Services (EOS) SDK uses the Friends Interface to retrieve the friends lists for a logged-in user. Friends lists are stored by the online service's servers, and can change during a session as friends are added or removed or if friends grant or revoke consent for the game to use their information.

Functions

These functions are provided for handling friend lists:

Constants

These are the constants used by this API:



Back To Top

EpicGames_Friends_AcceptInvite

Epic Online Services Function: EOS_Friends_AcceptInvite

This function starts an asynchronous task that accepts a friend invitation from another user. The completion delegate is executed after the backend response has been received.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

EpicGames_Friends_AcceptInvite(accountID, accountID_target)
Argument Type Description
accountID String The Epic Account ID of the local, logged-in user who is accepting the friends list invitation
accountID_target String The Epic Account ID of the user who sent the friends list invitation



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "EpicGames_Friends_AcceptInvite"
status EpicGames_Result The status code for the operation. EpicGames_Success indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = EpicGames_Friends_AcceptInvite(accountID, accountID_target);

The code sample above save the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "EpicGames_Friends_AcceptInvite")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EpicGames_Success)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

EpicGames_Friends_AddNotifyFriendsUpdate

Epic Online Services Function: EOS_Friends_AddNotifyFriendsUpdate

This function listens for changes to friends for a particular account.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

EpicGames_Friends_AddNotifyFriendsUpdate()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "EpicGames_Friends_AddNotifyFriendsUpdate"
CurrentStatus EpicGames_Friendship_Status The current status of the user.
PreviousStatus EpicGames_Friendship_Status The previous status of the user.
TargetUserId String The Epic Account ID of the user whose status is being updated.
LocalUserId String The Epic Account ID of the local user who is receiving the update

Example:

identifier = EpicGames_Friends_AddNotifyFriendsUpdate();

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "EpicGames_Friends_AddNotifyFriendsUpdate")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EpicGames_Success)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

EpicGames_Friends_GetFriendAtIndex

Epic Online Services Function: EOS_Friends_GetFriendAtIndex

This function retrieves the Epic Account ID of an entry from the friends list that has already been cached. The Epic Account ID returned by this function may belong to an account that has been invited to be a friend or that has invited the local user to be a friend. To determine if the Epic Account ID returned by this function is a friend or a pending friend invitation, use the EpicGames_Friends_GetStatus function.

Note

Requires a previous call to EpicGames_Friends_QueryFriends to store values in cache.


Syntax:

EpicGames_Friends_GetFriendAtIndex(accountID, index)
Argument Type Description
accountID String The user account Identifier to get the friend data from.
index Real Index into the friend list. This value must be between 0 and EpicGames_Friends_GetFriendsCount - 1 inclusively.



Returns:

String


Example:

var _count = EpicGames_Friends_GetFriendsCount(accountID);
for(var i = 0 ; i < _count; i++)
{
    var _friend_account = EpicGames_Friends_GetFriendAtIndex(accountID, i);
}

The above code shows an example of how the function should be used. The friend's data is returned providing an index.




Back To Top

EpicGames_Friends_GetFriendsCount

Epic Online Services Function: EOS_Friends_GetFriendsCount

This function retrieves the number of friends on the friends list.

Note

Requires a previous call to EpicGames_Friends_QueryFriends to store values in cache.


Syntax:

EpicGames_Friends_GetFriendsCount(accountID)
Argument Type Description
accountID String The Epic Account ID of the user whose friends should be counted



Returns:

Real


Example:

var _count = EpicGames_Friends_GetFriendsCount(accountID);
for(var i = 0 ; i < _count ; i++)
{
    var _friend_account = EpicGames_Friends_GetFriendAtIndex(accountID, i);
}

The above code shows an example of how the function should be used. After a successful call to EpicGames_Friends_QueryFriends, the function EpicGames_Friends_GetFriendsCount will return the number of entries in the query array which can then be accessed using the EpicGames_Friends_GetFriendAtIndex function.




Back To Top

EpicGames_Friends_GetStatus

Epic Online Services Function: EOS_Friends_GetStatus

This function retrieves the friendship status between the local user and another user.


Syntax:

EpicGames_Friends_GetStatus(accountID, accountID_target)
Argument Type Description
accountID String The Epic Account ID of the local, logged in user
accountID_target String The Epic Account ID of the user whose friendship status with the local user is being queried



Returns:

EpicGames_Friendship_Status


Example:

if(EpicGames_Friends_GetStatus(accountID,accountID_target) == EpicGames_FS_Friends)
{
     show_debug_message("It's my friend!!!");
}
else
{
     show_debug_message("Not my friend :(");
}

The above code shows an example of how the function should be used. The friendship status is returned from the function call.




Back To Top

EpicGames_Friends_QueryFriends

Epic Online Services Function: EOS_Friends_QueryFriends

This function starts an asynchronous task that reads the user's friends list from the backend service, caching it for future use. Once the callback has been fired with a successful EpicGames_Result, it is possible to call one of the following functions:

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

EpicGames_Friends_QueryFriends(accountID)
Argument Type Description
accountID String The Epic Account ID of the local, logged-in user whose friends list you want to retrieve



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "EpicGames_Friends_QueryFriends"
status EpicGames_Result The status code for the operation. EpicGames_Success indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = EpicGames_Friends_QueryFriends(accountID);

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "EpicGames_Friends_QueryFriends")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EpicGames_Success)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

EpicGames_Friends_RejectInvite

Epic Online Services Function: EOS_Friends_RejectInvite

This function starts an asynchronous task that rejects a friend invitation from another user. The completion delegate is executed after the backend response has been received.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

EpicGames_Friends_RejectInvite(accountID, accountID_target)
Argument Type Description
accountID String The Epic Account ID of the local, logged-in user who is rejecting a friends list invitation
accountID_target String The Epic Account ID of the user who sent the friends list invitation



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "EpicGames_Friends_RejectInvite"
status EpicGames_Result The status code for the operation. EpicGames_Success indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = EpicGames_Friends_RejectInvite(accountID, accountID_target);

The code sample above saves the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "EpicGames_Friends_RejectInvite")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EpicGames_Success)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}

The code above matches the response against the correct event type and logs the success of the task.




Back To Top

EpicGames_Friends_RemoveNotifyFriendsUpdate

Epic Online Services Function: EOS_Friends_RemoveNotifyFriendsUpdate

This function stop listening for friends changes on a previously bound handler.


Syntax:

EpicGames_Friends_RemoveNotifyFriendsUpdate(id)
Argument Type Description
id Real The handle representing the registered callback (return by EpicGames_Friends_AddNotifyFriendsUpdate)



Returns:

N/A


Example:

handle = EpicGames_Friends_AddNotifyFriendsUpdate();
//...
//...later
//...
EpicGames_Friends_RemoveNotifyFriendsUpdate(handle);

The code sample above enables the friend update notifications (EpicGames_Friends_AddNotifyFriendsUpdate) and later disables them by referring to the previously generated handle.




Back To Top

EpicGames_Friends_SendInvite

Epic Online Services Function: EOS_Friends_SendInvite

This function starts an asynchronous task that sends a friend invitation to another user. The completion delegate is executed after the backend response has been received. It does not indicate that the target user has responded to the friend invitation.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Social Async Event.


Syntax:

EpicGames_Friends_SendInvite(accountID, accountID_target)
Argument Type Description
accountID String The Epic Account ID of the local, logged-in user who is sending the friends list invitation
accountID_target String The Epic Account ID of the user who is receiving the friends list invitation



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "EpicGames_Friends_SendInvite"
status EpicGames_Result The status code for the operation. EpicGames_Success indicates that the operation succeeded; other codes indicate errors
status_message String Text representation of the status code
identifier Real The asynchronous listener ID.

Example:

identifier = EpicGames_Friends_SendInvite(accountID, accountID_target);

The code sample above save the identifier that can be used inside a Social Async Event.

if (async_load[? "type"] == "EpicGames_Friends_SendInvite")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EpicGames_Success)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
         show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}



Back To Top

EpicGames_Friendship_Status

Epic Online Services Enum: EOS_EFriendsStatus

These constants are used to describe the friendship status with a given account.

These constants are referenced by the following functions:


Member Description
EpicGames_FS_NotFriends The two accounts have no friendship status
EpicGames_FS_InviteSent The local account has sent a friend invite to the other account
EpicGames_FS_InviteReceived The other account has sent a friend invite to the local account
EpicGames_FS_Friends The accounts have accepted friendship

Clone this wiki locally