Package | com.smartfoxserver.v2.requests.game |
Class | public class JoinRoomInvitationRequest |
Inheritance | JoinRoomInvitationRequest com.smartfoxserver.v2.requests.BaseRequest |
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.
See also
Method | Defined By | ||
---|---|---|---|
JoinRoomInvitationRequest(targetRoom:Room, invitedUserNames:Array, params:ISFSObject = null, expirySeconds:int = 30, asSpectator:Boolean = false)
Creates a new JoinRoomInvitationRequest instance. | JoinRoomInvitationRequest |
JoinRoomInvitationRequest | () | Constructor |
public function JoinRoomInvitationRequest(targetRoom:Room, invitedUserNames:Array, params:ISFSObject = null, expirySeconds:int = 30, asSpectator:Boolean = false)
Creates a new JoinRoomInvitationRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.
ParameterstargetRoom:Room — The Room to join (must have free user/player slots).
| |
invitedUserNames:Array — A list of user names to invite.
| |
params:ISFSObject (default = null ) — An instance of SFSObject containing any relevant parameter or message to be sent to the invited users (for example an invitation message).
| |
expirySeconds:int (default = 30 ) — The time given to the invitee to reply to the invitation.
| |
asSpectator:Boolean (default = false ) — In Game Rooms only, indicates if the invited user(s) should join as spectator(s) instead of player(s).
|
See also
private function inviteMorePeople():void { sfs.addEventListener(SFSEvent.USER_ENTER_ROOM, onUserJoin); var invitedUsers:Array = ["Fozzie", "Piggy"]; var room:Room = sfs.getRoomByName("The Garden"); var params:ISFSObject = new SFSObject(); params.putUtfString("msg", "You are invited in this Room: " + room.name); sfs.send( new JoinRoomInvitationRequest(room, invitedUsers, params) ); } private function onUserJoin(evt:SFSEvent):void { trace("User joined Room: " + evt.params.user.name); }