Initializes the Buddy List system on the current client.

Namespace: Sfs2X.Requests.Buddylist
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.0.0 (1.7.0)

Syntax

C#
public class InitBuddyListRequest : BaseRequest

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:
 Copy imageCopy
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");       // Windows Universal
    // 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"]);      // Windows Universal
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests.Buddylist..::..InitBuddyListRequest

See Also