Ruyi SDK
Namespaces
Ruyi.SDK.Online
RuyiNetFriendService Class
RuyiNetFriendService Methods
Click or drag to resizeClick or drag to resize

RuyiNetFriendService Class

[This is preliminary documentation and is subject to change.]

A service for handling players' friend lists.
Inheritance Hierarchy
SystemObject
  Ruyi.SDK.OnlineRuyiNetService
    Ruyi.SDK.OnlineRuyiNetFriendService

Namespace:  Ruyi.SDK.Online
Assembly:  SDK.RuyiSDKAsync (in SDK.RuyiSDKAsync.dll) Version: 0.9.3.3995
Syntax
C#
Copy
public class RuyiNetFriendService : RuyiNetService

The RuyiNetFriendService type exposes the following members.

Methods
  NameDescription
Public methodAddFriend
Adds a user to the player's friend list.
Public methodGetProfile
Get the profile of the specified user.
Public methodGetProfiles
Get the profile of the specified users.
Public methodListFriends
Returns a list of the user's friends.
Public methodRemoveFriend
Removes a user from the player's friend list.
Top
Examples
Copy
using (var ruyi = RuyiSDK.CreateInstance(new RuyiSDKContext { endpoint = RuyiSDKContext.Endpoint.Console }))
{
    void printFriends(RuyiNetFriendSummaryData[] friends)
    {
        if (friends == null)
        {
            Console.WriteLine("ListFriends() failed");
            return;
        }
        foreach (var friend in friends)
        {
            Console.WriteLine(friend.Name);
        }
    }

    ruyi.RuyiNetService.Initialise(APP_ID, APP_SECRET, () =>
    {
        // Get friends BEFORE adding a friend
        ruyi.RuyiNetService.FriendService.ListFriends(0,
            (RuyiNetFriendSummaryData[] friendsBefore) =>
            {
                Console.WriteLine("Friends BEFORE:");
                printFriends(friendsBefore);

                // Add a friend
                ruyi.RuyiNetService.FriendService.AddFriend(0, FRIEND_PROFILE_ID,
                    (RuyiNetResponse response) =>
                    {
                        // Get friends AFTER adding a friend
                        ruyi.RuyiNetService.FriendService.ListFriends(0,
                            (RuyiNetFriendSummaryData[] friendsAfter) =>
                            {
                                Console.WriteLine("Friends After:");
                                printFriends(friendsAfter);
                            }
                            );
                    });
            });
    });

    while (ruyi.RuyiNetService.IsWorking) { ruyi.Update(); }
}
See Also

Reference

Ruyi.SDK.Online Namespace

Copyright ©Zhongshan Subor Advanced Technology Co., Ltd. 2017-2018, All right reserved

Send comments on this topic to dev-support@playruyi.com