Click or drag to resize

InitBuddyListRequest Class

Initializes the Buddy List system on the current client.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.BuddylistInitBuddyListRequest

Namespace:  Sfs2X.Requests.Buddylist
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class InitBuddyListRequest : BaseRequest

The InitBuddyListRequest type exposes the following members.

Constructors
  NameDescription
Public methodInitBuddyListRequest
Creates a new InitBuddyListRequest instance.
Top
Remarks
Buddy List system initialization involves loading any previously stored buddy-specific data from the server, such as the current user's buddies list, his previous state and the persistent Buddy Variables. The initialization request is the first operation to be executed in order to be able to use the Buddy List system features. Once the initialization is completed, the BUDDY_LIST_INIT event id fired and the user has access to all his previously set data and can start to interact with his buddies; if the initialization failed, a BUDDY_ERROR event id fired.
Examples
The following example initializes the Buddy List system:
void SomeMethod() {
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_LIST_INIT, OnBuddyInited);
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);

    // Initialize the Buddy List system
    sfs.Send(new InitBuddyListRequest());
}

void OnBuddyInited(BaseEvent evt) {
    Console.WriteLine("Buddy List system initialized successfully");                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Buddy List system initialized successfully");       // UWP

    // Retrieve my buddies list
    List<Buddy> buddies = sfs.BuddyManager.BuddyList;

    // Display the online buddies in a list component in the application interface
    ...
}

void OnBuddyError(BaseEvent evt) {
    Console.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]);                       // .Net / Unity
    System.Diagnostics.Debug.WriteLine("The following error occurred while executing a buddy-related request: " + (string)evt.Params["errorMessage"]);      // UWP
}
See Also