Click or drag to resize

JoinRoomInvitationRequest Class

Sends an invitation to other users/players to join a specific Room.
Inheritance Hierarchy
SystemObject
  BaseRequest
    Sfs2X.Requests.GameJoinRoomInvitationRequest

Namespace:  Sfs2X.Requests.Game
Assembly:  SmartFox2X (in SmartFox2X.dll) Version: 1.8.0.0 (1.8.0)
Syntax
C#
public class JoinRoomInvitationRequest : BaseRequest
Constructors
Remarks
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.

Depending on the Room's settings this invitation can be sent by the Room's owner only or by any other user. This behavior can be set via the RoomSettings.AllowOwnerOnlyInvitation parameter.

NOTE: spectators in a Game Room are not allowed to invite other users; only players are.

An invitation can also specify the amount of time given to each invitee to reply. Default is 30 seconds. A positive answer will attempt to join the user in the designated Room. For Game Rooms the asSpectator flag can be toggled to join the invitee as player or spectator (default = player).

There aren't any specific notifications sent back to the inviter after the invitee's response. Users that have accepted the invitation will join the Room while those who didn't reply or turned down the invitation won't generate any event. In order to send specific messages (e.g. chat), just send a private message back to the inviter.

Examples
The following example invites two more users in the current game:
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, onUserJoin);

    List<string> invitedUsers = new List<string>(){"Fozzie", "Piggy"};
       Room room = sfs.GetRoomByName("The Garden");

    // Add message to be shown to the invited users
    ISFSObject params = SFSObject.NewInstance();
    params.PutUtfString("msg", "You are invited in this Room: " + room.Name);

    // Send the request
    sfs.Send( new JoinRoomInvitationRequest(room, invitedUsers, params) );
}

void onUserJoin(BaseEvent evt) {
    User user = (User)evt.Params["user"];

    Console.WriteLine("Room joined by: " + user.Name);                        // .Net / Unity
    System.Diagnostics.Debug.WriteLine("Room joined by: " + user.Name);        // UWP
}
See Also