Class SFS2X.Entities.Variables.SFSBuddyVariable

The Buddy Variable entity representation on the client.

Class Summary
Constructor Attributes Constructor Name and Description
 
Creates a new SFSBuddyVariable instance.

Field Summary

Method Summary

Class Detail

SFS2X.Entities.Variables.SFSBuddyVariable(name, value, type)
Creates a new SFSBuddyVariable instance.

A SFSBuddyVariable is a custom value attached to a SFSBuddy 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 ranking, a status message, etc. Buddy Variables can be set by means of the SetBuddyVariablesRequest request; they support the following data types (also nested): Boolean, Number, String, Object, Array. 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 List, 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.

Parameters:
{String} name
The name of the Buddy Variable.
{*} value
The value of the Buddy Variable; valid data types are: Boolean, Number, String, Object, Array. The value can also be null.
{Number} type Optional, Default: -1
The type id 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:
SFS2X.Entities.Variables.VariableType
SFS2X.Entities.SFSBuddy
SFS2X.Requests.BuddyList.SetBuddyVariablesRequest

Field Detail

<static> <constant> SFS2X.Entities.Variables.SFSBuddyVariable.OFFLINE_PREFIX
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 List, whether that Buddy is online or not.

Method Detail

  • {Boolean} isOffline()
    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 List, whether that Buddy is online or not.

    Returns:
    {Boolean} true if the Buddy Variable is persistent.
  • {String} toString()
    Returns a string that contains the Buddy Variable name, type and value.
    Returns:
    {String} The string representation of the SFSBuddyVariable object.