Packagecom.smartfoxserver.v2.requests.game
Classpublic class InviteUsersRequest
InheritanceInviteUsersRequest Inheritance com.smartfoxserver.v2.requests.BaseRequest

Sends a generic invitation to a list of users.

Invitations can be used for different purposes, such as requesting users to join a game or visit a specific Room, asking the permission to add them as buddies, etc. 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.

View the examples

See also

invitation event
InvitationReplyRequest


Public Methods
 MethodDefined By
  
InviteUsersRequest(invitedUsers:Array, secondsForAnswer:int, params:ISFSObject)
Creates a new InviteUsersRequest instance.
InviteUsersRequest
Constructor Detail
InviteUsersRequest()Constructor
public function InviteUsersRequest(invitedUsers:Array, secondsForAnswer:int, params:ISFSObject)

Creates a new InviteUsersRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Parameters
invitedUsers:Array — A list of User objects representing the users to send the invitation to.
 
secondsForAnswer:int — The number of seconds available to each invited user to reply to the invitation (recommended range: 15 to 40 seconds).
 
params:ISFSObject — An instance of SFSObject containing custom parameters which specify the invitation details.

See also

Examples
The following example sends an invitation to join the current user in his private Room; the invitation contains a custom message and the Room name and password, so that the recipient clients can join the Room if the users accept the invitation:
     
     private function someMethod():void
     {
         // Add a listener to the invitation reply
         sfs.addEventListener(SFSEvent.INVITATION_REPLY, onInvitationReply);
         
         // Choose the invitation recipients
         var friend1:User = sfs.userManager.getUserByName("Piggy");
         var friend2:User = sfs.userManager.getUserByName("Gonzo");
         
         // Set the custom invitation details
         var params:ISFSObject = new SFSObject();
         params.putUtfString("msg", "Would you like to join me in my private room?");
         params.putUtfString("roomName", "Kermit's room");
         params.putUtfString("roomPwd", "drowssap");
         
         // Send the invitation; recipients have 20 seconds to reply before the invitation expires
         sfs.send(new InviteUsersRequest([friend1, friend2], 20, params));
     }
     
     private function onInvitationReply(evt:SFSEvent):void
     {
         // If at least one recipient accepted the invitation, make me join my private Room to meet him there
         if (evt.params.reply == InvitationReply.ACCEPT)
         {
             var currentRoom:Room = sfs.lastJoinedRoom;
             
             if (currentRoom.name != "Kermit's room")
                 sfs.send(new JoinRoomRequest("Kermit's room"));
         }
         else
         {
             trace(evt.params.invitee + " refused the invitation")
         }
     }