Class SFS2X.Requests.Game.InvitationReplyRequest

Replies to an invitation received by the current user.

Class Summary
Constructor Attributes Constructor Name and Description
SFS2X.Requests.Game.InvitationReplyRequest(invitation, invitationReply, params)
Creates a new InvitationReplyRequest instance.

Class Detail

SFS2X.Requests.Game.InvitationReplyRequest(invitation, invitationReply, params)
Creates a new InvitationReplyRequest instance. The instance must be passed to the SmartFox.send() method for the request to be performed.

Users who receive an invitation sent by means of the InviteUsersRequest request can either accept or refuse it using this request. The reply causes an invitationReply event to be dispatched to the inviter; if a reply is not sent, or it is sent after the invitation expiration, the system will react as if the invitation was refused.

If an error occurs while the reply is delivered to the inviter user (for example the invitation is already expired), an invitationReplyError event is returned to the current user.

The following example receives an invitation and accepts it automatically; in a real case scenario, the application interface usually allows the user choosing to accept or refuse the invitation, or even ignore it:

function someMethod()
	sfs.addEventListener(SFS2X.SFSEvent.INVITATION, onInvitationReceived, this);
	sfs.addEventListener(SFS2X.SFSEvent.INVITATION_REPLY_ERROR, onInvitationReplyError, this);

function onInvitationReceived(evtParams)
	// Let's accept this invitation
	sfs.send(new SFS2X.Requests.Game.InvitationReplyRequest(evtParams.invitation, SFS2X.Entities.Invitation.InvitationReply.ACCEPT));

function onInvitationReplyError(evtParams)
	console.log("Failed to reply to invitation due to the following problem: " + evtParams.errorMessage);
{Invitation} invitation
An instance of the Invitation class containing the invitation details (inviter, custom parameters, etc).
{Number} invitationReply
The answer to be sent to the inviter, among those available as constants in the InvitationReply class.
{Object} params Optional, Default: null
An object containing custom parameters to be returned to the inviter together with the reply (for example a message describing the reason of refusal).
See also: