Class AdminMessageRequest

  • All Implemented Interfaces:
    sfs2x.client.requests.IRequest

    public class AdminMessageRequest
    extends sfs2x.client.requests.GenericMessageRequest
    Sends an administrator message to a specific user or a group of users.

    The current user must have administration privileges to be able to send the message (see the User.privilegeId property).

    The recipientMode parameter in the class constructor is used to determine the message recipients: a single user or all the users in a Room, a Group or the entire Zone. Upon message delivery, the clients of the recipient users dispatch the adminMessage event.

    Example
    The following example sends an administration message to all the users in the Zone; it also shows how to handle the related event:

     private void someMethod() {
         sfs.addEventListener(SFSEvent.ADMIN_MESSAGE, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 System.out.println("The administrator sent the following message: " + evt.getArguments().get("message"));
             }
         });
         
         // Set the message recipients: all users in the Zone
         MessageRecipientMode recipMode = new MessageRecipientMode(MessageRecipientMode.TO_ZONE, null);
         
         // Send the administrator message
         sfs.send(new AdminMessageRequest("Hello to everybody from the Administrator!", recipMode));
     }
     
    See Also:
    SFSEvent.ADMIN_MESSAGE, User.getPrivilegeId(), ModeratorMessageRequest
    • Constructor Detail

      • AdminMessageRequest

        public AdminMessageRequest​(java.lang.String message,
                                   MessageRecipientMode recipientMode,
                                   com.smartfoxserver.v2.entities.data.ISFSObject params)
        Creates a new AdminMessageRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
        Parameters:
        message - The message of the administrator to be sent to the target user/s defined by the recipientMode parameter.
        recipientMode - An instance of MessageRecipientMode containing the target to which the message should be delivered.
        params - An instance of SFSObject containing custom parameters to be sent to the recipient user/s.
        See Also:
        SmartFox.send(sfs2x.client.requests.IRequest), SFSObject