World of Hello
Public Member Functions | List of all members
CreateServerObject Class Reference

An object that is stored in the server. More...

#include <CreateServerObject.h>

Public Member Functions

 CreateServerObject ()
 creates a server object. More...
 
string getObject ()
 get the object as a string. More...
 
void setProperty (string property, string value)
 sets a property of the object. More...
 
string getProperty (string property)
 gets the value of a set property. More...
 
string[] getProperties ()
 gets all properties from the object. More...
 
void removeProperty (string property)
 removes a property from the object. More...
 
void clearProperties ()
 removes all properties from the object. See removeProperty() More...
 
void sendToClients (bool removeOthers=false, string key="", string keyAns="")
 sends the object to all connected clients who meet the criteria. More...
 
void removeFromClients ()
 removes the object from all online clients. More...
 
void setID (string ID)
 set the ID of the object. More...
 
string getID ()
 get the ID of the object. More...
 
void remove ()
 removes the object. More...
 
void doCommands (string cmd)
 creates the element from an object like a server command. More...
 

Detailed Description

An object that is stored in the server.

   A ServerObject is an object that can be sent to the server and stored.\n
   This allows you to create your own receivable objects rather than using other types, such as elements or mesh.\n
   Unlike commands sent using server:sendToClients(), a ServerObject is stored into the server, sent to clients who have the required key and key content (if any given),
   and is removed when the key is lost.\n
   When elements and mesh are sent to the server, they use this class under the covers.

Constructor & Destructor Documentation

◆ CreateServerObject()

CreateServerObject::CreateServerObject ( )

creates a server object.

   Creates an object that can be stored in the server.\n
   WARNING: this object is not sent to the server until sendToClients() has been called.

Member Function Documentation

◆ clearProperties()

void CreateServerObject::clearProperties ( )

removes all properties from the object. See removeProperty()

◆ doCommands()

void CreateServerObject::doCommands ( string  cmd)

creates the element from an object like a server command.

   Uses the given comma-separated properties and creates the element like a command.
   You may get the object (see getProperties()) and use this function to make the element
   load the same data as the given object.
Parameters
Theobject command.
Returns
Returns itself.

◆ getID()

string CreateServerObject::getID ( )

get the ID of the object.

Returns
The ID of the object.

◆ getObject()

string CreateServerObject::getObject ( )

get the object as a string.

   Gets the object and all of it's set properties as a string object.
   Can be used to save the object into a data file.
Returns
The element as an object string.

◆ getProperties()

string [] CreateServerObject::getProperties ( )

gets all properties from the object.

Returns
All properties of the object.

◆ getProperty()

string CreateServerObject::getProperty ( string  property)

gets the value of a set property.

Parameters
Theproperty to get the value of.
Returns
The value of the given property.

◆ remove()

void CreateServerObject::remove ( )

removes the object.

   Destroys the object, removing it completely.\n
   If the object is stored in the server and isn't a static object (see setID()), it is also removed from the server and all clients who have the object.

◆ removeFromClients()

void CreateServerObject::removeFromClients ( )

removes the object from all online clients.

   Removes the object from all online clients.\n
   WARNING: this does not remove the object from the user.\n
   WARNING: this removes the object entirely from the server.

◆ removeProperty()

void CreateServerObject::removeProperty ( string  property)

removes a property from the object.

   Note that setting the property's value to an empty string will also call removeProperty().
Parameters
Theproperty to be removed.

◆ sendToClients()

void CreateServerObject::sendToClients ( bool  removeOthers = false,
string  key = "",
string  keyAns = "" 
)

sends the object to all connected clients who meet the criteria.

   Sends the object to all clients who are connected to this world.\n
   The object is then stored in the server based on it's ID (see object:setID()).
Parameters
(optional)Whether or not all of the object's properties are required to be sent.
(optional)The send key who all clients must have in order to get the object.
(optional)The send key value all clients must also have.

◆ setID()

void CreateServerObject::setID ( string  ID)

set the ID of the object.

   Sets the ID of the object. By default, the object has a unique ID.\n
   WARNING: If the ID has a minus sign ("-") at the beginning of the new ID to be set,
   the ID will remain static, even for online objects when being sent. Otherwise if there is no minus sign,
   a unique ID will be generated for online objects, and the online object (if sent) will be removed by default on disconnect.\n
   For example, if you want to create an online object only one time total that all clients can see and modify (opposed to one online object per client),
   you may want to add a minus sign to the beginning of the ID. Used in the case of real-time editing game town elements.
Parameters
Thenew ID to be set.

◆ setProperty()

void CreateServerObject::setProperty ( string  property,
string  value 
)

sets a property of the object.

   Sets a property of the object.\n
   The property is then sent to clients who meet the given criteria (see ServerObject:sendToClients()) and can be caught as a command.\n
   WARNING: Setting the value to an empty string removes the property.
Parameters
Theproperty to be set.
Thevalue of the property.