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

Sends a generic invitation to a list of users. More...

#include <InviteUsersRequest.h>

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

Public Member Functions

 InviteUsersRequest (std::vector< Invitee > invitedUsers, int32_t secondsForAnswer, std::shared_ptr< entities::SFSObject > params=nullptr)
 Creates a new InviteUsersRequest.

Static Public Attributes

static constexpr int32_t MIN_EXPIRY_TIME = 5
 The minimum number of seconds the invitees can be given to reply to an invitation.
static constexpr int32_t MAX_EXPIRY_TIME = 300
 The maximum number of seconds the invitees can be given to reply to an invitation.
static constexpr std::size_t MAX_INVITATIONS_FROM_CLIENT_SIDE = 8
 The maximum number of users that can be invited from the client side.

Detailed Description

Sends a generic invitation to a list of users.

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 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.

Each reply comes back to the inviter as an event::SFSEvent::INVITATION_REPLY event, one per invited user; the invitations that are left unanswered produce one too, carrying an EXPIRED reply, as soon as the time given to answer runs out.

What an accepted invitation does is entirely up to the developer: the server takes no action of its own. The one exception is JoinRoomInvitationRequest, which builds on the same mechanism to join the invitee in a Room.

auto params = std::make_shared<entities::SFSObject>();
params->putShortString("msg", "Come and play with us!");

std::vector<requests::Invitee> invitees { user1, user2 };
sfs.send(requests::inv::InviteUsersRequest(std::move(invitees), 20, params));
See also
event::SFSEvent::INVITATION
event::SFSEvent::INVITATION_REPLY
InvitationReplyRequest
JoinRoomInvitationRequest

Constructor & Destructor Documentation

◆ InviteUsersRequest()

sfs3::requests::inv::InviteUsersRequest::InviteUsersRequest ( std::vector< Invitee > invitedUsers,
int32_t secondsForAnswer,
std::shared_ptr< entities::SFSObject > params = nullptr )
inline

Creates a new InviteUsersRequest.

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

Parameters
invitedUsersthe users to send the invitation to; no more than MAX_INVITATIONS_FROM_CLIENT_SIDE. The current user is skipped if listed: nobody can invite himself
secondsForAnswerthe number of seconds available to each invited user to reply to the invitation (recommended range: 15 to 40 seconds)
paramsthe custom parameters describing the invitation, such as a message for the recipient; optional
See also
SmartFox::send

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