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

Namespace: Sfs2X.Requests
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.3.0 (1.7.3)

Syntax

C#
public class ObjectMessageRequest : GenericMessageRequest

Remarks

The data object is delivered to the selected users (or all users excluding the sender) inside the target Room by means of the 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.

Examples

The following example sends the player's character movement coordinates and handles the respective event:
 Copy imageCopy
void SomeMethod() {
    sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
    // Send a game move to all players
    ISFSObject dataObj = new SFSObject();
    dataObj.PutInt("x", myAvatar.x);
    dataObj.PutInt("y", myAvatar.y);
    sfs.Send( new ObjectMessageRequest(dataObj) );
}
void OnObjectMessage(BaseEvent evt) {
    ISFSObject dataObj = (SFSObject)evt.Params["message"];
    int x = dataObj.GetInt("x");
    int y = dataObj.GetInt("y");
    // etc...
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    GenericMessageRequest
      Sfs2X.Requests..::..ObjectMessageRequest

See Also