InviteUsersRequest Class |
Namespace: Sfs2X.Requests.Game
public class InviteUsersRequest : BaseRequest
The InviteUsersRequest type exposes the following members.
Name | Description | |
---|---|---|
InviteUsersRequest |
Creates a new InviteUsersRequest instance.
|
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(friend1); invitedUsers.Add(friend2); // 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"); // UWP } }