|
SmartFoxServer 3 C++ Client API 3.1.0-beta
Client API for SmartFoxServer 3
|
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. | |
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 });
|
inline |
Creates a new ObjectMessageRequest.
Pass it to SmartFox::send for the request to be performed.
| obj | The custom parameters to be sent to the message recipients. Only borrowed: it is copied into the request before SmartFox::send returns. |
| targetRoom | The Room where the message should be dispatched; if nullptr, the last Room joined by the user is used. |
| recipients | The users the message is addressed to; if empty, the message is sent to all the users in the target Room (except the sender itself). |