Class ChangeRoomPasswordStateRequest

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

    public class ChangeRoomPasswordStateRequest
    extends BaseRequest
    Changes the password of a Room. This request not only changes the password of a Room, but also its "password state", which indicates if the Room is password protected or not.

    If the operation is successful, the roomPasswordStateChange event is dispatched to all the users who subscribed the Group to which the target Room belongs, including the requester user himself. If the user is not the creator (owner) of the Room the roomPasswordStateChangeError event if fired. An administrator or moderator can override the constraint (he is not requested to be the Room's owner).

    If the Room was configured so that password change is not allowed (see the RoomSettings.permissions parameter), the request is ignored and no error is fired.

    Example
    The following example changes the password of an existing Room:

     private void someMethod() {
         sfs.addEventListener(SFSEvent.ROOM_PASSWORD_STATE_CHANGE, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 System.out.println("The password of Room " + ((Room)evt.getArguments().get("room")).getName() + " was changed successfully");
             }
         });
         
         sfs.addEventListener(SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 System.out.println("Room password change failed: " + evt.getArguments().get("errorMessage"));
             }
         });
         
         Room theRoom = sfs.getRoomByName("Gonzo's Room");
         
         // Change the Room's password state, so that it becomes password protected
         sfs.send(new ChangeRoomPasswordStateRequest(theRoom, "mammamia"));
     }
     
    See Also:
    SFSEvent.ROOM_PASSWORD_STATE_CHANGE, SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, RoomSettings.getPermissions()
    • Field Detail

      • KEY_ROOM

        public static final java.lang.String KEY_ROOM
        * API internal usage only *
        See Also:
        Constant Field Values
      • KEY_PASS

        public static final java.lang.String KEY_PASS
        * API internal usage only *
        See Also:
        Constant Field Values
    • Constructor Detail

      • ChangeRoomPasswordStateRequest

        public ChangeRoomPasswordStateRequest​(Room room,
                                              java.lang.String newPass)
        Creates a new ChangeRoomPasswordStateRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
        Parameters:
        room - The Room object corresponding to the Room whose password should be changed.
        newPass - The new password to be assigned to the Room; an empty string or the null value can be passed to remove the Room's password.
        See Also:
        SmartFox.send(sfs2x.client.requests.IRequest)
    • Method Detail

      • validate

        public void validate​(ISmartFox sfs)
                      throws sfs2x.client.exceptions.SFSValidationException
        * API internal usage only *
        Throws:
        sfs2x.client.exceptions.SFSValidationException
      • execute

        public void execute​(ISmartFox sfs)
        * API internal usage only *