Adds a new buddy to the current user's buddies list.

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


public class AddBuddyRequest : BaseRequest


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).


The following example sends a request to add a buddy:
 Copy imageCopy
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"]);       // Windows Universal
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


See Also