Package | com.smartfoxserver.v2.entities.variables |
Class | public class SFSBuddyVariable |
Inheritance | SFSBuddyVariable BaseVariable Object |
Implements | BuddyVariable |
Buddy Variables work with the same principle of the User and Room Variables. The only difference is the logic by which they get propagated to other users. While Room and User Variables are usually broadcast to all clients in the same Room, Buddy Variables updates are sent to all users who have the owner of the Buddy Variable in their Buddy Lists.
Buddy Variables are particularly useful to store custom user data that must be "visible" to the buddies only, such as a profile, a score, a status message, etc.
Buddy Variables can be set by means of the SetBuddyVariablesRequest request; they support the following data types (also nested):
Boolean, int, Number, String, SFSObject, SFSArray. A Buddy Variable can also be null
.
There is also a special convention that allows Buddy Variables to be set as "offline".
Offline Buddy Variables are persistent values which are made available to all users who have the owner in their Buddy Lists, whether that Buddy is online or not.
In order to make a Buddy Variable persistent, its name should start with a dollar sign ($
).
This conventional character is contained in the OFFLINE_PREFIX constant.
See also
Property | Defined By | ||
---|---|---|---|
isOffline : Boolean [read-only]
Indicates whether the Buddy Variable is persistent or not. | SFSBuddyVariable | ||
name : String [read-only]
Indicates the name of this variable. | BaseVariable | ||
type : String [read-only]
Indicates the type of this variable. | BaseVariable |
Method | Defined By | ||
---|---|---|---|
SFSBuddyVariable(name:String, value:*, type:int = -1)
Creates a new SFSBuddyVariable instance. | SFSBuddyVariable | ||
getBoolValue():Boolean
Retrieves the value of a boolean variable. | BaseVariable | ||
getDoubleValue():Number
Retrieves the value of a numeric variable. | BaseVariable | ||
getIntValue():int
Retrieves the value of an integer variable. | BaseVariable | ||
Retrieves the value of a SFSArray variable. | BaseVariable | ||
Retrieves the value of a SFSObject variable. | BaseVariable | ||
getStringValue():String
Retrieves the value of a string variable. | BaseVariable | ||
getValue():*
Retrieves the untyped value of this variable. | BaseVariable | ||
isNull():Boolean
Indicates if the variable is null. | BaseVariable | ||
toString():String
Returns a string that contains the Buddy Variable name, type and value. | SFSBuddyVariable |
Constant | Defined By | ||
---|---|---|---|
OFFLINE_PREFIX : String = $ [static]
The prefix to be added to a Buddy Variable name to make it persistent. | SFSBuddyVariable |
isOffline | property |
isOffline:Boolean
[read-only] Indicates whether the Buddy Variable is persistent or not.
By convention any Buddy Variable whose name starts with the dollar sign ($
) will be regarded as persistent and stored locally by the server.
Persistent Buddy Variables are also referred to as "offline variables" because they are available to all users
who have the owner in their Buddy Lists, whether that Buddy is online or not.
public function get isOffline():Boolean
SFSBuddyVariable | () | Constructor |
public function SFSBuddyVariable(name:String, value:*, type:int = -1)
Creates a new SFSBuddyVariable instance.
Parametersname:String — The name of the Buddy Variable.
| |
value:* — The value of the Buddy Variable; valid data types are: Boolean, int, Number, String, SFSObject, SFSArray. The value can also be null .
| |
type:int (default = -1 ) — The type of the Buddy Variable among those available in the VariableType class. Usually it is not necessary to pass this parameter, as the type is auto-detected from the value.
|
See also
toString | () | method |
public function toString():String
Returns a string that contains the Buddy Variable name, type and value.
ReturnsString — The string representation of the SFSBuddyVariable object.
|
OFFLINE_PREFIX | Constant |
public static const OFFLINE_PREFIX:String = $
The prefix to be added to a Buddy Variable name to make it persistent. A persistent Buddy Variable is made available to all users who have the owner in their Buddy Lists, whether that Buddy is online or not.