Class: SFSBuddyVariable

SFSBuddyVariable


The SFSBuddyVariable class represents a Buddy Variable, a custom value attached to a Buddy in a Buddy List.

Buddy Variables work with the same principle of the User/Room Variables. The only difference is the logic by which they get propagated to other users: while Room Variables are broadcast to all clients in the same Room, Buddy Variables are sent to all users who have the variable owner in their Buddy Lists.
They support basic data types and nested complex objects:

  • null
  • boolean
  • int (32 bit integer)
  • double (64 bit double precision number)
  • utf-string (UTF-8 encoded string, with length up to 32 KBytes)
  • SFSObject
  • SFSArray

Notes

  • For members of the SFSBuddyVariable class, please refer to its Javadoc.
  • Buddy Variables provide a special convention that allows variables to be "seen" by the buddies even if the owner is not online. All variable names starting with a dollar sign ($) will be persistent and available at any time whether the owner is online or not.

See also


new SFSBuddyVariable(name, value [, type])

Creates a new SFSBuddyVariable instance.

Although the third parameter is optional, it is strongly recommended to use it. The reason is type autodetection of numbers (being integers or double precision numbers) may fail in some corner cases (for example n1 = Math.floor(100.0 - 99.0) will be treated as a double instead of an integer as expected).

Parameters:
Name Type Argument Default Description
name string The name of the Buddy Variable.
value boolean | number | string | SFSObject | SFSArray The value of the Buddy Variable; it can also be null.
type VariableType <optional>
null The type of the Buddy Variable's value, among those listed in the VariableType enum; if null, type is autodetected.