Class SFSBuddyVariable

java.lang.Object
com.smartfoxserver.entities.variables.BaseVariable
com.smartfoxserver.buddylist.SFSBuddyVariable
All Implemented Interfaces:
BuddyVariable, Variable, Serializable, Cloneable

public class SFSBuddyVariable extends com.smartfoxserver.entities.variables.BaseVariable implements BuddyVariable
BuddyVariables are custom values attached to any Buddy in a BuddyList. They 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 RoomVariables are broadcast to all clients in the same Room, BuddyVariables are updated to all Users who have the BuddyVariable owner in their BuddyLists.

BuddyVariables support basic data types and nested complex objects:

  • Null
  • Bool
  • Int
  • Double
  • String
  • SFSObject
  • SFSArray

Also BuddyVariables provide a special convention that allows certain variables to be "seen" to the other Users even when they are 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:
  • Field Details

  • Constructor Details

    • SFSBuddyVariable

      public SFSBuddyVariable(String name, Object value)
    • SFSBuddyVariable

      protected SFSBuddyVariable()
    • SFSBuddyVariable

      protected SFSBuddyVariable(String name, Object value, VariableType type)
  • Method Details

    • newFromSFSArray

      public static SFSBuddyVariable newFromSFSArray(ISFSArray array)
      SFSArray is expected to be formatted as follows 0: (str) - name 1: (byte) - type id 2: (*) - value
      Parameters:
      array -
      Returns:
      the RoomVariable
    • isOffline

      public boolean isOffline()
      Description copied from interface: BuddyVariable
      Checks if this is a "offline" variable (persistent), which is available to other Users even when the client is not online.
      Specified by:
      isOffline in interface BuddyVariable
      Returns:
      true if the variable is persistent
    • toSFSArray

      public ISFSArray toSFSArray()
      Specified by:
      toSFSArray in interface Variable
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object