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

Joins the current user in a Room. More...

#include <JoinRoomRequest.h>

Inheritance diagram for sfs3::requests::JoinRoomRequest:
[legend]

Public Member Functions

 JoinRoomRequest (int32_t roomId, std::optional< std::string > pass=std::nullopt, std::optional< int32_t > roomIdToLeave=std::nullopt, bool asSpect=false)
 Creates a new JoinRoomRequest for the Room with the given id.
 JoinRoomRequest (std::optional< std::string > name, std::optional< std::string > pass=std::nullopt, std::optional< int32_t > roomIdToLeave=std::nullopt, bool asSpect=false)
 Creates a new JoinRoomRequest for the Room with the given name.
 JoinRoomRequest (entities::Room *theRoom, std::optional< std::string > pass=std::nullopt, std::optional< int32_t > roomIdToLeave=std::nullopt, bool asSpect=false)
 Creates a new JoinRoomRequest for the given Room.

Detailed Description

Joins the current user in a Room.

On success the current user receives a event::SFSEvent::ROOM_JOIN event, otherwise a event::SFSEvent::ROOM_JOIN_ERROR event. A join usually fails because the Room is full, or because the password is wrong for a Room that is protected by one.

Two more events can be fired, depending on the events setting the Room got at creation time: the other users inside the Room get a event::SFSEvent::USER_ENTER_ROOM event, and every client that subscribed the Group of the Room gets a event::SFSEvent::USER_COUNT_CHANGE event.

See also
event::SFSEvent::ROOM_JOIN
event::SFSEvent::ROOM_JOIN_ERROR
event::SFSEvent::USER_ENTER_ROOM
event::SFSEvent::USER_COUNT_CHANGE
RoomSettings::events

Constructor & Destructor Documentation

◆ JoinRoomRequest() [1/3]

sfs3::requests::JoinRoomRequest::JoinRoomRequest ( int32_t roomId,
std::optional< std::string > pass = std::nullopt,
std::optional< int32_t > roomIdToLeave = std::nullopt,
bool asSpect = false )

Creates a new JoinRoomRequest for the Room with the given id.

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

Parameters
roomIdThe id of the Room to join.
passThe password of the Room, if it is protected by one.
roomIdToLeaveThe id of a Room joined before, which the user leaves when it joins the new one. When it is empty the last joined Room is left; pass a negative number to leave no Room at all.
asSpecttrue to join the Room as a spectator. Game Rooms only.
See also
SmartFox::send

◆ JoinRoomRequest() [2/3]

sfs3::requests::JoinRoomRequest::JoinRoomRequest ( std::optional< std::string > name,
std::optional< std::string > pass = std::nullopt,
std::optional< int32_t > roomIdToLeave = std::nullopt,
bool asSpect = false )

Creates a new JoinRoomRequest for the Room with the given name.

Parameters
nameThe name of the Room to join.
passThe password of the Room, if it is protected by one.
roomIdToLeaveThe id of a Room joined before, which the user leaves when he joins the new one.
asSpecttrue to join the Room as a spectator. Game Rooms only.
See also
JoinRoomRequest::JoinRoomRequest(int32_t, std::optional<std::string>, std::optional<int32_t>, bool)

◆ JoinRoomRequest() [3/3]

sfs3::requests::JoinRoomRequest::JoinRoomRequest ( entities::Room * theRoom,
std::optional< std::string > pass = std::nullopt,
std::optional< int32_t > roomIdToLeave = std::nullopt,
bool asSpect = false )

Creates a new JoinRoomRequest for the given Room.

Parameters
theRoomThe Room to join. The caller keeps the ownership.
passThe password of the Room, if it is protected by one.
roomIdToLeaveThe id of a Room joined before, which the user leaves when he joins the new one.
asSpecttrue to join the Room as a spectator. Game Rooms only.
See also
JoinRoomRequest::JoinRoomRequest(int32_t, std::optional<std::string>, std::optional<int32_t>, bool)

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