Click or drag to resize

AddBuddyRequest Class

Adds a new buddy to the current user's buddies list.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.BuddylistAddBuddyRequest

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

The AddBuddyRequest type exposes the following members.

Constructors
  NameDescription
Public methodAddBuddyRequest
Creates a new AddBuddyRequest instance.
Top
Remarks
In order to add a buddy, the current user must be online in the Buddy List system. If the buddy is added successfully, the operation is confirmed by a BUDDY_ADD event; otherwise the BUDDY_ERROR event is fired.

This request can be sent if the Buddy List system was previously initialized only (see the InitBuddyListRequest request description).

Examples
The following example sends a request to add a buddy:
void SomeMethod() {
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_ADD, OnBuddyAdded);
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);

    // Add Jack as a new buddy to my buddies list
    sfs.Send(new AddBuddyRequest("Jack"));
}

void OnBuddyAdded(BaseEvent evt) {
    Console.WriteLine("Buddy was added: " + (Buddy)evt.Params["buddy"]);                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Buddy was added: " + (Buddy)evt.Params["buddy"]);       // UWP
}

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