sfs2x.client.requests
Class ModeratorMessageRequest

java.lang.Object
  extended by sfs2x.client.requests.BaseRequest
      extended by sfs2x.client.requests.GenericMessageRequest
          extended by sfs2x.client.requests.ModeratorMessageRequest
All Implemented Interfaces:
sfs2x.client.requests.IRequest

public class ModeratorMessageRequest
extends sfs2x.client.requests.GenericMessageRequest

Sends a moderator message to a specific user or a group of users.

The current user must have moderation 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 moderatorMessage event.

Example
The following example sends a moderator message to all the users in the last joined Room; it also shows how to handle the related event:

 private void someMethod() {
     sfs.addEventListener(SFSEvent.MODERATOR_MESSAGE, new IEventListener() {
         public void dispatch(BaseEvent evt) throws SFSException {
             System.out.println("The moderator sent the following message: " + evt.getArguments().get("message"));
         }
     });
     
     // Set the message recipients: all users in the current Room
     MessageRecipientMode recipMode = new MessageRecipientMode(MessageRecipientMode.TO_ROOM, sfs.getLastJoinedRoom());
     
     // Send the moderator message
     sfs.send(new ModeratorMessageRequest("Hello everybody, I'm the Moderator!", recipMode));
 }
 

See Also:
SFSEvent.MODERATOR_MESSAGE, User.getPrivilegeId(), AdminMessageRequest

Field Summary
 
Fields inherited from class sfs2x.client.requests.GenericMessageRequest
KEY_MESSAGE, KEY_MESSAGE_TYPE, KEY_RECIPIENT, KEY_RECIPIENT_MODE, KEY_ROOM_ID, KEY_SENDER_DATA, KEY_USER_ID, KEY_XTRA_PARAMS
 
Fields inherited from class sfs2x.client.requests.BaseRequest
AddBuddy, AdminMessage, AutoJoin, BanUser, BlockBuddy, CallExtension, ChangeRoomCapacity, ChangeRoomName, ChangeRoomPassword, CreateRoom, CreateSFSGame, FindRooms, FindUsers, GenericMessage, GetRoomList, GoOnline, Handshake, InitBuddyList, InvitationReply, InviteUser, JoinRoom, JoinRoomInvite, KEY_ERROR_CODE, KEY_ERROR_PARAMS, KickUser, LeaveRoom, Login, Logout, ManualDisconnection, ModeratorMessage, ObjectMessage, PingPong, PlayerToSpectator, PrivateMessage, PublicMessage, QuickJoinGame, RemoveBuddy, SetBuddyVariables, SetRoomVariables, SetUserPosition, SetUserVariables, SpectatorToPlayer, SubscribeRoomGroup, UnsubscribeRoomGroup
 
Constructor Summary
ModeratorMessageRequest(java.lang.String message, MessageRecipientMode recipientMode)
           
ModeratorMessageRequest(java.lang.String message, MessageRecipientMode recipientMode, com.smartfoxserver.v2.entities.data.ISFSObject params)
          Creates a new ModeratorMessageRequest instance.
 
Method Summary
 
Methods inherited from class sfs2x.client.requests.GenericMessageRequest
execute, validate
 
Methods inherited from class sfs2x.client.requests.BaseRequest
getId, getMessage, getTargetController, isEncrypted, setEncrypted, setId, setTargetController
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModeratorMessageRequest

public ModeratorMessageRequest(java.lang.String message,
                               MessageRecipientMode recipientMode,
                               com.smartfoxserver.v2.entities.data.ISFSObject params)
Creates a new ModeratorMessageRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters:
message - The message of the moderator 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

ModeratorMessageRequest

public ModeratorMessageRequest(java.lang.String message,
                               MessageRecipientMode recipientMode)
See Also:
ModeratorMessageRequest(String, MessageRecipientMode, ISFSObject)