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

Sends a public chat message. More...

#include <PublicMessageRequest.h>

Public Member Functions

 PublicMessageRequest (std::string message, const entities::SFSObject *params=nullptr, std::shared_ptr< entities::Room > targetRoom=nullptr)
 Creates a new PublicMessageRequest.

Detailed Description

Sends a public chat message.

A public message is dispatched to all the users in the specified Room, including the message sender (this allows showing messages in the correct order in the application interface); the corresponding event is the event::SFSEvent::PUBLIC_MESSAGE event. It is also possible to send an optional object together with the message: it can contain custom parameters useful to transmit, for example, additional informations related to the message, like the text font or color, or other formatting details.

In case the target Room is not specified, the message is sent in the last Room joined by the sender.

NOTE: the event::SFSEvent::PUBLIC_MESSAGE event is dispatched if the Room is configured to allow public messaging only (see the RoomSettings::permissions parameter).

entities::SFSObject params;
params.putShortString("color", "#FF0000");

sfs.send(requests::PublicMessageRequest { "Hello everyone!", &params });
See also
event::SFSEvent::PUBLIC_MESSAGE
RoomSettings::permissions

Constructor & Destructor Documentation

◆ PublicMessageRequest()

sfs3::requests::PublicMessageRequest::PublicMessageRequest ( std::string message,
const entities::SFSObject * params = nullptr,
std::shared_ptr< entities::Room > targetRoom = nullptr )
inline

Creates a new PublicMessageRequest.

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

Parameters
messageThe message to be sent to all the users in the target Room.
paramsAdditional custom parameters to be sent to the message recipients (for example the color of the text, etc); nullptr if none. Only borrowed: it is copied into the request before SmartFox::send returns.
targetRoomThe Room where the message should be dispatched; if nullptr, the last Room joined by the user is used.
See also
SmartFox::send
entities::SFSObject

The documentation for this class was generated from the following file:
  • requests/PublicMessageRequest.h