Skip to content

Friends

Francisco Dias edited this page Nov 17, 2022 · 7 revisions

Back To Top

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:

  • EpicGames_Friends_AcceptInvite
  • EpicGames_Friends_AddNotifyFriendsUpdate
  • EpicGames_Friends_GetFriendAtIndex
  • EpicGames_Friends_GetFriendsCount
  • EpicGames_Friends_GetStatus
  • EpicGames_Friends_QueryFriends
  • EpicGames_Friends_RejectInvite
  • EpicGames_Friends_RemoveNotifyFriendsUpdate
  • EpicGames_Friends_SendInvite

Constants

These are the constants used by this API:




Back To Top

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 is an asynchronous function that will trigger the Social Async Event when the task is finished.

✴️ EXTERNAL

A wrapper around EOS_Friends_AcceptInvite


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:

Asynchronous Social Event
Key Type Description
type string The string "EpicGames_Friends_AcceptInvite"
status EResult 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 an Async Social 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

Listen for changes to friends for a particular account. This is an asynchronous function that will trigger the Social Async Event when the task is finished.

✴️ EXTERNAL

A wrapper around EOS_Friends_AddNotifyFriendsUpdate


Syntax:

EpicGames_Friends_AddNotifyFriendsUpdate()

Returns:

real

Triggers:

Asynchronous Social 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 save the identifier that can be used inside an Async Social 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

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.

✴️ EXTERNAL

A wrapper around EOS_Friends_GetFriendAtIndex


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 will show an example of how the function should be used. The friends data is returned providing an index.




Back To Top

Retrieves the number of friends on the friends list.

ℹ️ NOTE

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

✴️ EXTERNAL

A wrapper around EOS_Friends_GetFriendsCount


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 account = EpicGames_Friends_GetFriendsCount(accountID)
for(var i = 0 ; i < account ; i++)
{
    var friend_account = EpicGames_Friends_GetFriendAtIndex(accountID,i)
}

The above code will show an example of how the function should be used. After a successcull 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

Retrieve the friendship status between the local user and another user.

✴️ EXTERNAL

A wrapper around EOS_Friends_GetStatus


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:

real (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 will show an example of how the function should be used. The friendship status is returned from the function call.




Back To Top

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:

  • EpicGames_Friends_GetFriendAtIndex

  • EpicGames_Friends_GetFriendsCount

    This is an asynchronous function that will trigger the Social Async Event when the task is finished.

✴️ EXTERNAL

A wrapper around EOS_Friends_QueryFriends


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:

N/A

Triggers:

Asynchronous Social Event
Key Type Description
type string The string "EpicGames_Friends_QueryFriends"
status EResult 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 save the identifier that can be used inside an Async Social 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

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 is an asynchronous function that will trigger the Social Async Event when the task is finished.

✴️ EXTERNAL

A wrapper around EOS_Friends_RejectInvite


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:

Asynchronous Social Event
Key Type Description
type string The string "EpicGames_Friends_RejectInvite"
status EResult 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 save the identifier that can be used inside an Async Social 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

Stop listening for friends changes on a previously bound handler.

✴️ EXTERNAL

A wrapper around EOS_Friends_RemoveNotifyFriendsUpdate


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 refering to the previous generated handle.




Back To Top

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 is an asynchronous function that will trigger the Social Async Event when the task is finished.

✴️ EXTERNAL

A wrapper around EOS_Friends_SendInvite


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:

Asynchronous Social Event
Key Type Description
type string The string "EpicGames_Friends_SendInvite"
status EResult 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 an Async Social 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"])
    }
}

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




Clone this wiki locally