Class JoinRoomInvitationRequest

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

    public class JoinRoomInvitationRequest
    extends BaseRequest
    • Constructor Detail

      • JoinRoomInvitationRequest

        public JoinRoomInvitationRequest​(Room targetRoom,
                                         java.util.List<java.lang.String> invitedUserNames)
        Sends an invitation to other users/players to join a specific Room.

        Invited users receive the invitation as an invitation event dispatched to their clients: they can accept or refuse it by means of the InvitationReplyRequest request, which must be sent within the specified amount of time.

        Depending on the Room's settings the invitation can be sent by the Room's owner only or by any other user. This behavior can be set via the RoomSettings.allowOwnerOnlyInvitation parameter.

        NOTE: spectators in a Game Room are not allowed to invite other users; only players are.

        An invitation can also specify the amount of time given to each invitee to reply. Default is 30 seconds. A positive answer will attempt to join the user in the designated Room. For Game Rooms the asSpectator flag can be toggled to join the invitee as player or spectator (default = player).

        There aren't any specific notifications sent back to the inviter after the invitee's response. Users that have accepted the invitation will join the Room while those who didn't reply or turned down the invitation won't generate any event. In order to send specific messages (e.g. chat), just send a private message back to the inviter.

        The following example invites two more users in the current game:

         
         private void inviteMorePeople()
         {
            sfs.addEventListener(SFSEvent.USER_ENTER_ROOM, new UserJoinListener());
            
                  List invitedUsers = Arrays.asList("Fozzie", "Piggy");
            Room room = sfs.getRoomByName("The Garden");
            
            ISFSObject params = new SFSObject();
            params.putUtfString("msg", "You are invited in this Room: " + room.name);
            
            sfs.send( new JoinRoomInvitationRequest(room, invitedUsers, params) );
         }
         
         private class UserJoinListener implements IEventListener
         {
             public void dispatch(BaseEvent evt) throws SFSException 
             {
                        User player = (User) evt.getArguments().get("user");
             
                        trace("User joined Room: " + user.getName());
             }
         }
         
         
        Since:
        1.7.0
        See Also:
        RoomSettings
      • JoinRoomInvitationRequest

        public JoinRoomInvitationRequest​(Room targetRoom,
                                         java.util.List<java.lang.String> invitedUserNames,
                                         com.smartfoxserver.v2.entities.data.ISFSObject params,
                                         int expirySeconds)
      • JoinRoomInvitationRequest

        public JoinRoomInvitationRequest​(Room targetRoom,
                                         java.util.List<java.lang.String> invitedUserNames,
                                         com.smartfoxserver.v2.entities.data.ISFSObject params,
                                         int expirySeconds,
                                         boolean asSpectator)
    • Method Detail

      • validate

        public void validate​(ISmartFox sfs)
                      throws sfs2x.client.exceptions.SFSValidationException
        Throws:
        sfs2x.client.exceptions.SFSValidationException
      • execute

        public void execute​(ISmartFox sfs)
                     throws com.smartfoxserver.v2.exceptions.SFSException
        Throws:
        com.smartfoxserver.v2.exceptions.SFSException