SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
Loading...
Searching...
No Matches
sfs3::requests::inv::JoinRoomInvitationRequest Class Reference

Sends an invitation to other users/players to join a specific Room. More...

#include <JoinRoomInvitationRequest.h>

Inheritance diagram for sfs3::requests::inv::JoinRoomInvitationRequest:
[legend]

Public Member Functions

 JoinRoomInvitationRequest (const entities::Room &targetRoom, std::vector< std::string > invitedUserNames, std::shared_ptr< entities::SFSObject > params=nullptr, int32_t expirySeconds=DEFAULT_EXPIRY_SECONDS, bool asSpectator=false)
 Creates a new JoinRoomInvitationRequest.

Static Public Attributes

static constexpr int32_t DEFAULT_EXPIRY_SECONDS = 30
 The number of seconds the invitees are given to reply, when not specified.

Detailed Description

Sends an invitation to other users/players to join a specific Room.

Invited users receive the invitation as an event::SFSEvent::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 the invitation can be sent by the Room's owner only or by any other user; this behavior is set through RoomSettings::allowOwnerOnlyInvitation at creation time. NOTE: spectators in a Game Room are not allowed to invite other users; only players are.

A positive answer joins the invitee in the designated Room. For Game Rooms the asSpectator flag decides whether he joins as a player or as a spectator.

The inviter gets no notification when an invitation is accepted, only when it is refused or left to expire: an event::SFSEvent::INVITATION_REPLY event is dispatched in those two cases alone, the acceptance showing instead as the invitee entering the Room. To send anything more specific back to the inviter (a chat message, for instance) reply to him with a private message.

The Zone can be configured to only accept invitations directed at the inviter's buddies, and it caps how many users a single request can invite; recipients that don't qualify are silently dropped server side.

std::vector<std::string> invitees { "Piggy", "Gonzo" };
sfs.send(requests::inv::JoinRoomInvitationRequest(*sfs.getLastJoinedRoom(), std::move(invitees)));
See also
event::SFSEvent::INVITATION
event::SFSEvent::INVITATION_REPLY
InvitationReplyRequest
RoomSettings

Constructor & Destructor Documentation

◆ JoinRoomInvitationRequest()

sfs3::requests::inv::JoinRoomInvitationRequest::JoinRoomInvitationRequest ( const entities::Room & targetRoom,
std::vector< std::string > invitedUserNames,
std::shared_ptr< entities::SFSObject > params = nullptr,
int32_t expirySeconds = DEFAULT_EXPIRY_SECONDS,
bool asSpectator = false )
inline

Creates a new JoinRoomInvitationRequest.

Pass it to SmartFox::send for the request to be performed.

Parameters
targetRoomthe Room to invite the users to join
invitedUserNamesthe names of the users to invite
paramsthe custom parameters describing the invitation, such as a message for the recipients; optional
expirySecondsthe number of seconds available to each invited user to reply to the invitation
asSpectatorwhether the invitees should join a Game Room as spectators instead of players; ignored by regular Rooms
See also
SmartFox::send

The documentation for this class was generated from the following files:
  • requests/invitation/JoinRoomInvitationRequest.h
  • requests/invitation/JoinRoomInvitationRequest.cpp