friends - YoYoGames/GMEXT-EpicOnlineServices GitHub Wiki

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

eos_friends_accept_invite

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:

eos_friends_accept_invite(account_id, account_id_target)
Argument Type Description
account_id String The Epic Account ID of the local, logged-in user who is accepting the friends list invitation
account_id_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 "eos_friends_accept_invite"
status EOS_RESULT The status code for the operation. EOS_RESULT.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 = eos_friends_accept_invite(account_id, account_id_target);

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

if (async_load[? "type"] == "eos_friends_accept_invite")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.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

eos_friends_add_notify_friends_update

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:

eos_friends_add_notify_friends_update()



Returns:

Real


Triggers:

Social Async Event

Key Type Description
type String The string "eos_friends_add_notify_friends_update"
current_status EOS_FRIENDS_STATUS The current status of the user.
previous_status EOS_FRIENDS_STATUS The previous status of the user.
target_user_id String The Epic Account ID of the user whose status is being updated.
local_user_id String The Epic Account ID of the local user who is receiving the update

Example:

identifier = eos_friends_add_notify_friends_update();

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

if (async_load[? "type"] == "eos_friends_add_notify_friends_update")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.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

eos_friends_get_friend_at_index

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 eos_friends_get_status function.

Note

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


Syntax:

eos_friends_get_friend_at_index(account_id, index)
Argument Type Description
account_id 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 eos_friends_get_friends_count - 1 inclusively.



Returns:

String


Example:

var _count = eos_friends_get_friends_count(account_id);
for(var i = 0 ; i < _count; i++)
{
    var _friend_account = eos_friends_get_friend_at_index(account_id, 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

eos_friends_get_friends_count

Epic Online Services Function: EOS_Friends_GetFriendsCount

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

Note

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


Syntax:

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



Returns:

Real


Example:

var _count = eos_friends_get_friends_count(account_id);
for(var i = 0 ; i < _count ; i++)
{
    var _friend_account = eos_friends_get_friend_at_index(account_id, i);
}

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




Back To Top

eos_friends_get_status

Epic Online Services Function: EOS_Friends_GetStatus

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


Syntax:

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



Returns:

EOS_FRIENDS_STATUS


Example:

if(eos_friends_get_status(account_id,account_id_target) == EOS_FRIENDS_STATUS.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

eos_friends_query_friends

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 EOS_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:

eos_friends_query_friends(account_id)
Argument Type Description
account_id 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 "eos_friends_query_friends"
status EOS_RESULT The status code for the operation. EOS_RESULT.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 = eos_friends_query_friends(account_id);

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

if (async_load[? "type"] == "eos_friends_query_friends")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.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

eos_friends_reject_invite

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:

eos_friends_reject_invite(account_id, account_id_target)
Argument Type Description
account_id String The Epic Account ID of the local, logged-in user who is rejecting a friends list invitation
account_id_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 "eos_friends_reject_invite"
status EOS_RESULT The status code for the operation. EOS_RESULT.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 = eos_friends_reject_invite(account_id, account_id_target);

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

if (async_load[? "type"] == "eos_friends_reject_invite")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.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

eos_friends_remove_notify_friends_update

Epic Online Services Function: EOS_Friends_RemoveNotifyFriendsUpdate

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


Syntax:

eos_friends_remove_notify_friends_update(id)
Argument Type Description
id Real The handle representing the registered callback (return by eos_friends_add_notify_friends_update)



Returns:

N/A


Example:

handle = eos_friends_add_notify_friends_update();
//...
//...later
//...
eos_friends_remove_notify_friends_update(handle);

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




Back To Top

eos_friends_send_invite

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:

eos_friends_send_invite(account_id, account_id_target)
Argument Type Description
account_id String The Epic Account ID of the local, logged-in user who is sending the friends list invitation
account_id_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 "eos_friends_send_invite"
status EOS_RESULT The status code for the operation. EOS_RESULT.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 = eos_friends_send_invite(account_id, account_id_target);

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

if (async_load[? "type"] == "eos_friends_send_invite")
if (async_load[? "identifier"] == identifier)
{
    if (async_load[? "status"] == EOS_RESULT.SUCCESS)
    {
        show_debug_message(async_load[? "type"] + " succeeded!");
    }
    else
    {
        show_debug_message(async_load[? "type"] + " failed: " + async_load[? "status_message"]);
    }
}



Back To Top

EOS_FRIENDS_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
NOT_FRIENDS The two accounts have no friendship status
INVITE_SENT The local account has sent a friend invite to the other account
INVITE_RECEIVED The other account has sent a friend invite to the local account
FRIENDS The accounts have accepted friendship

⚠️ **GitHub.com Fallback** ⚠️