Click or drag to resize

BlockBuddyRequest Class

Blocks or unblocks a buddy in the current user's buddies list. Blocked buddies won't be able to send messages or requests to that user.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.BuddylistBlockBuddyRequest

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

The BlockBuddyRequest type exposes the following members.

Constructors
  NameDescription
Public methodBlockBuddyRequest
Creates a new BlockBuddyRequest instance.
Top
Remarks
In order to block a buddy, the current user must be online in the Buddy List system. If the operation is successful, a BUDDY_BLOCK confirmation event is dispatched; 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 block a buddy:
void SomeMethod() {
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_BLOCK, onBuddyBlock);
    sfs.AddEventListener(SFSBuddyEvent.BUDDY_ERROR, OnBuddyError);

    // Block Jack in my buddies list
    sfs.Send(new BlockBuddyRequest("Jack", true));
}

void onBuddyBlock(BaseEvent evt) {
    Buddy buddy = (Buddy)evt.Params["buddy"];
    Console.WriteLine("Buddy " + buddy.Name + " is now " + (buddy.IsBlocked ? "blocked" : "unblocked"));                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Buddy " + buddy.Name + " is now " + (buddy.IsBlocked ? "blocked" : "unblocked"));       // 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