InviteUsersRequest
Sends a generic invitation to a list of users.
// Choose the invitation recipients
var friend1 = sfs.userManager.getUserByName("Piggy");
var friend2 = sfs.userManager.getUserByName("Gonzo");
// Set the custom invitation details
var params = new SFS2X.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 SFS2X.InviteUsersRequest([friend1, friend2], 20, params));
}
function onInvitationReply(evtParams) { // If at least one recipient accepted the invitation, make me join my private Room to meet him there if (evtParams.reply == SFS2X.InvitationReply.ACCEPT) { var currentRoom = sfs.lastJoinedRoom;
if (currentRoom.name != "Kermit's room")
sfs.send(new SFS2X.JoinRoomRequest("Kermit's room"));
}
else
{
console.log(evtParams.invitee + " refused the invitation");
}
}
new InviteUsersRequest(invitedUsers, secondsForAnswer[, params])
Creates a new InviteUsersRequest instance. The instance must be passed to the SmartFox.send() method for the request to be executed.
This request 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.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
invitedUsers |
|
|
A list of SFSUser objects, each representing a user to send the invitation to. |
secondsForAnswer |
|
|
The number of seconds available to each invited user to reply to the invitation (recommended range: 15 to 40 seconds). |
params |
|
Yes |
An SFSObject containing custom parameters containing additional invitation details. Defaults to |