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

Sends an object containing custom data to all users in a Room, or a subset of them. More...

#include <ObjectMessageRequest.h>

Public Member Functions

 ObjectMessageRequest (const entities::SFSObject &obj, std::shared_ptr< entities::Room > targetRoom=nullptr, std::vector< std::shared_ptr< entities::User > > recipients={})
 Creates a new ObjectMessageRequest.

Detailed Description

Sends an object containing custom data to all users in a Room, or a subset of them.

The data object is delivered to the selected users (or all users excluding the sender) inside the target Room by means of the event::SFSEvent::OBJECT_MESSAGE event. It can be useful to send game data, like for example the target coordinates of the user's avatar in a virtual world.

Recipients that are not joined in the target Room are dropped, with a warning, before the request leaves the client.

entities::SFSObject obj;
obj.putInt("x", 120);
obj.putInt("y", 40);

sfs.send(requests::ObjectMessageRequest { obj });
See also
event::SFSEvent::OBJECT_MESSAGE

Constructor & Destructor Documentation

◆ ObjectMessageRequest()

sfs3::requests::ObjectMessageRequest::ObjectMessageRequest ( const entities::SFSObject & obj,
std::shared_ptr< entities::Room > targetRoom = nullptr,
std::vector< std::shared_ptr< entities::User > > recipients = {} )
inline

Creates a new ObjectMessageRequest.

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

Parameters
objThe custom parameters to be sent to the message recipients. 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.
recipientsThe users the message is addressed to; if empty, the message is sent to all the users in the target Room (except the sender itself).
See also
SmartFox::send
entities::SFSObject
entities::User

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