Sends a generic invitation to a list of users.

Namespace: Sfs2X.Requests.Game
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.3.0 (1.7.3)

Syntax

C#
public class InviteUsersRequest : BaseRequest

Remarks

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.

Examples

The following example sends an invitation to join the current user in his private Room; the invitation contains a custom message and the Room name and password, so that the recipient clients can join the Room if the users accept the invitation:
 Copy imageCopy
void SomeMethod() {
    // Add a listener to the invitation reply
    sfs.AddEventListener(SFSEvent.INVITATION_REPLY, OnInvitationReply);
    // Choose the invitation recipients
    User friend1 = sfs.UserManager.GetUserByName("Piggy");
    User friend2 = sfs.UserManager.GetUserByName("Gonzo");
    List<object> invitedUsers = new List<object>();
    invitedUsers.Add(user1);
    invitedUsers.Add(user2);
    // Set the custom invitation details
    ISFSObject parameters = new SFSObject();
    parameters.PutUtfString("msg", "Would you like to join me in my private room?");
    parameters.PutUtfString("roomName", "Kermit's room");
    parameters.PutUtfString("roomPwd", "drowssap");
    // Send the invitation; recipients have 20 seconds to reply before the invitation expires
    sfs.Send( new InviteUsersRequest(invitedUsers, 20, parameters) );
}
void OnInvitationReply(BaseEvent evt) {
    // If at least one recipient accepted the invitation, make me join my private Room to meet him there
    if ((InvitationReply)evt.Params["reply"] == InvitationReply.ACCEPT) {
        Room currentRoom = sfs.LastJoinedRoom;
        if (currentRoom.name != "Kermit's room")
            sfs.Send(new JoinRoomRequest("Kermit's room"));
    }
    else ((InvitationReply)evt.Params["reply"] == InvitationReply.REFUSE) {
        Console.WriteLine((User)evt.Params["invitee"] + " refused the invitation");                         // .Net / Unity
        System.Diagnostics.Debug.WriteLine((User)evt.Params["invitee"] + " refused the invitation");        // Windows Universal
    }
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests.Game..::..InviteUsersRequest

See Also