Class SetRoomVariablesRequest

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

    public class SetRoomVariablesRequest
    extends BaseRequest
    Sets one or more custom Room Variables in a Room.

    When a Room Variable is set, the roomVariablesUpdate event is dispatched to all the users in the target Room, including the user who updated it. Also, if the Room Variable is global (see the SFSRoomVariable class description), the event is dispatched to all users who subscribed the Group to which the target Room is associated.

    Example
    The following example sets a number of Room Variables and handles the respective update event:

     private void someMethod() {
         sfs.addEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, new IEventListener() {
             public void dispatch(BaseEvent evt) throws SFSException {
                 List changedVars = (List)evt.getArguments().get("changedVars");
                 Room room = (Room)evt.getArguments().get("room");
                 
                 // Check if the "gameStarted" variable was changed
                 if (changedVars.indexOf("gameStarted") != -1)
                 {
                     if (room.getVariable("gameStarted").getBoolValue() == true)
                         System.out.println("Game started");
                     else
                         System.out.println("Game stopped");
                 }
             }
         });
         
         // Create some Room Variables
         List roomVars = new ArrayList();
         roomVars.add(new SFSRoomVariable("gameStarted", false));
         roomVars.add(new SFSRoomVariable("gameType", "Snooker"));
         roomVars.add(new SFSRoomVariable("minRank", 10));
         
         sfs.send(new SetRoomVariablesRequest(roomVars));
     }
     
    See Also:
    SFSEvent.ROOM_VARIABLES_UPDATE, SFSRoomVariable
    • Field Detail

      • KEY_VAR_ROOM

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

        public static final java.lang.String KEY_VAR_LIST
        * API internal usage only *
        See Also:
        Constant Field Values
    • 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 *