new ClusterInviteUsersRequest(target, invitedUsers, secondsForAnswer[, params])

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

In the SmartFoxServer 2X Cluster environment, this request sends a generic invitation to a list of users to join a Room on a Game Node. 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.

If the invitation is accepted, and the invited user is not yet connected to the target Game Node, the connectionRequired event is dispatched to the their client, followed by a roomJoin event after the connection and login process is completed. In case the client is already connected to the target Game Node, the roomJoin event is received immediately.

Example

This example sends an invitation to join the current user in their current Game Room.

function someMethod()
{
	// Set target Game Node and Room
	var target = new SFS2X.ClusterTarget(sfsGame.nodeId, sfsGame.lastJoinedRoom.id);

	// Choose the invitation recipients
	var friend1 = sfsLobby.buddyManager.getBuddyByName("Piggy");
	var friend2 = sfsLobby.buddyManager.getBuddyByName("Gonzo");

	// Set the custom invitation details
	var params = new SFS2X.SFSObject();
	params.putUtfString("msg", "Would you like to join me in my private room?");

	// Send the invitation; recipients have 20 seconds to reply before the invitation expires
	sfsLobby.send(new SFS2X.ClusterInviteUsersRequest(target, [friend1, friend2], 20, params));
}

Parameters

Name Type Optional Description

target

 

 

A ClusterTarget object containing the identifiers of the Game Node and Room the users are invited to join.

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 null.

See also
SmartFox#send
InvitationReplyRequest
SFSEvent.INVITATION
SFSEvent.INVITATION_REPLY