Click or drag to resize

InvitationReplyRequest Class

Replies to an invitation received by the current user.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.GameInvitationReplyRequest

Namespace:  Sfs2X.Requests.Game
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class InvitationReplyRequest : BaseRequest
Constructors
  NameDescription
Public methodInvitationReplyRequest(Invitation, InvitationReply)
See InvitationReplyRequest(Invitation, InvitationReply, ISFSObject) constructor.
Public methodInvitationReplyRequest(Invitation, InvitationReply, ISFSObject)
Creates a new InvitationReplyRequest instance.
Top
Remarks
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 INVITATION_REPLY 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 INVITATION_REPLY_ERROR event is returned to the current user.

Examples
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:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.INVITATION, OnInvitationReceived);
    sfs.AddEventListener(SFSEvent.INVITATION_REPLY_ERROR, OnInvitationReplyError);
}

void OnInvitationReceived(BaseEvent evt) {
    // Let's accept this invitation
    sfs.Send( new InvitationReplyRequest((Invitation)evt.Params["invitation"], InvitationReply.ACCEPT) );
}

void OnInvitationReplyError(BaseEvent evt) {
    Console.WriteLine("Failed to reply to invitation due to the following problem: " + (string)evt.Params["errorMessage"]);                         // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Failed to reply to invitation due to the following problem: " + (string)evt.Params["errorMessage"]);        // UWP
}
See Also