Packagecom.smartfoxserver.v2.entities.variables
Classpublic class SFSBuddyVariable
InheritanceSFSBuddyVariable Inheritance BaseVariable Inheritance Object
Implements BuddyVariable

The SFSBuddyVariable object represents a SmartFoxServer Buddy Variable entity on the client. It is a custom value attached to a Buddy object in a Buddy List that gets automatically synchronized between client and server on every change.

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

OFFLINE_PREFIX
Buddy
SetBuddyVariablesRequest


Public Properties
 PropertyDefined By
  isOffline : Boolean
[read-only] Indicates whether the Buddy Variable is persistent or not.
SFSBuddyVariable
 Inheritedname : String
[read-only] Indicates the name of this variable.
BaseVariable
 Inheritedtype : String
[read-only] Indicates the type of this variable.
BaseVariable
Public Methods
 MethodDefined By
  
SFSBuddyVariable(name:String, value:*, type:int = -1)
Creates a new SFSBuddyVariable instance.
SFSBuddyVariable
 Inherited
getBoolValue():Boolean
Retrieves the value of a boolean variable.
BaseVariable
 Inherited
Retrieves the value of a numeric variable.
BaseVariable
 Inherited
Retrieves the value of an integer variable.
BaseVariable
 Inherited
Retrieves the value of a SFSArray variable.
BaseVariable
 Inherited
Retrieves the value of a SFSObject variable.
BaseVariable
 Inherited
Retrieves the value of a string variable.
BaseVariable
 Inherited
Retrieves the untyped value of this variable.
BaseVariable
 Inherited
isNull():Boolean
Indicates if the variable is null.
BaseVariable
  
toString():String
Returns a string that contains the Buddy Variable name, type and value.
SFSBuddyVariable
Public Constants
 ConstantDefined By
  OFFLINE_PREFIX : String = $
[static] The prefix to be added to a Buddy Variable name to make it persistent.
SFSBuddyVariable
Property Detail
isOfflineproperty
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.


Implementation
    public function get isOffline():Boolean
Constructor Detail
SFSBuddyVariable()Constructor
public function SFSBuddyVariable(name:String, value:*, type:int = -1)

Creates a new SFSBuddyVariable instance.

Parameters
name: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

Method Detail
toString()method
public function toString():String

Returns a string that contains the Buddy Variable name, type and value.

Returns
String — The string representation of the SFSBuddyVariable object.
Constant Detail
OFFLINE_PREFIXConstant
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.