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.

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

Syntax

C#
public class BlockBuddyRequest : BaseRequest

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:
 Copy imageCopy
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"));       // 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

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

See Also