Class SFSBuddy

  • All Implemented Interfaces:
    Buddy

    public class SFSBuddy
    extends java.lang.Object
    implements Buddy

    Introduction

    The SFSBuddy class represent a Buddy in the User's Buddy List. Each Buddy has several properties:
    • name: the name of the Buddy, corresponds ot the User name
    • nickname: an optional nickname (default = null)
    • isOnline: whether the Buddy is online in the Buddy system or not
    • state: a string representing a "state message", such as: Available, Busy...
    • isBlocked: whether the Buddy is blocked in the User Buddy List
    • isTemp: a temporary Buddy is not stored in the Buddy List, it will be removed at the end of the session (see below)
    • variables: the Buddy variables which can be transient or persistent (see below)

    Online State

    Any user can decide if they want to be online/off-line as Buddy in the Buddy system. By default a User is online every time he joins the Zone, but the User can also turn off this flag at runtime and disappear from other User's buddy lists. The Online State is persistent and based on a reserved Buddy Variable.

    Blocked Buddies

    Buddies that are blocked won't be able to send any messages to the User, also they won't be able to see if the Buddy is online/off-line.

    Buddy State message

    The state message represents a typical IM Buddy state such as Available, Busy etc... By default the system already provides 3 default states: Available, Away, Occupied which can be changed or enriched at any time The state message is based on a reserved Buddy Variable.

    Temp Buddy

    A temporary Buddy is added to the User List when another User adds me to his Buddy List. This way we can see each others and exchange messages. If I don't add the User as Buddy in my list the User will remain temporary and it won't be persisted.

    Variables

    Buddy Variables enable each Buddy to show/send updates for specific informations to each User that has the Buddy in the list. For example one could send real-time updates on his last activity (ala Twitter) or post the title of the song he's listening right now, scores, rankings and whatnot.

    Advanced Topics

    Persistence

    The BuddyList system also provides a persistence interface that can be implemented by the User to store the BuddyList data to any datas source. The default BuddyList system stores the BuddyLists in the file system under the data/buddylists/ folder.

    Server Side Events

    The Buddy system exposes many server side events that you can listen for in your extensions to add extra behaviors to the system such, as sending permission requests to becoming a Buddy, mutual add/remove Buddy etc...
    See Also:
    BuddyListManager, ReservedBuddyVariables, BuddyStorage, SFSEvent
    • Constructor Detail

      • SFSBuddy

        public SFSBuddy​(java.lang.String name)
      • SFSBuddy

        public SFSBuddy​(java.lang.String name,
                        boolean isTemp)
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: Buddy
        The Buddy name, which corresponds to the User name.
        Specified by:
        getName in interface Buddy
        Returns:
        the name of the buddy
      • getParentBuddyList

        public BuddyList getParentBuddyList()
        Description copied from interface: Buddy
        Return the parent BuddyList containing this Buddy
        Specified by:
        getParentBuddyList in interface Buddy
        Returns:
        the parent BuddyList
      • setParentBuddyList

        public void setParentBuddyList​(BuddyList parentList)
        Description copied from interface: Buddy
        Set the parent BuddyList
        Specified by:
        setParentBuddyList in interface Buddy
        Parameters:
        parentList - the BuddyList
      • getState

        public java.lang.String getState()
        Description copied from interface: Buddy
        Returns the current Buddy State
        Specified by:
        getState in interface Buddy
        Returns:
        the current buddy states
      • getNickName

        public java.lang.String getNickName()
        Description copied from interface: Buddy
        Get the nickname of the Buddy. By default no Buddies have no nickname set
        Specified by:
        getNickName in interface Buddy
      • hasVariables

        public boolean hasVariables()
        Description copied from interface: Buddy
        Checks if the Buddy has at least one variable set
        Specified by:
        hasVariables in interface Buddy
        Returns:
        true if at least 1 variable exists for this buddy
      • getVariable

        public BuddyVariable getVariable​(java.lang.String varName)
        Description copied from interface: Buddy
        Get a Buddy Variable from its name
        Specified by:
        getVariable in interface Buddy
        Parameters:
        varName - the variable name
        Returns:
        the BuddyVariable or null if no variables was ever set with that name
      • getVariables

        public java.util.List<BuddyVariable> getVariables()
        Description copied from interface: Buddy
        Get all BuddyVariables
        Specified by:
        getVariables in interface Buddy
        Returns:
        a List with all the BuddyVariables
      • isBlocked

        public boolean isBlocked()
        Description copied from interface: Buddy
        When a Buddy is blocked he won't be able to see the User status and send him messages
        Specified by:
        isBlocked in interface Buddy
        Returns:
        true if the Buddy is blocked
      • isOnline

        public boolean isOnline()
        Description copied from interface: Buddy
        Checks if the Buddy is active in the system
        Specified by:
        isOnline in interface Buddy
        Returns:
        true if the Buddy is online
      • isTemp

        public boolean isTemp()
        Description copied from interface: Buddy
        A temporary Buddy will only exist at runtime but will be lost as soon as he goes away or the user is disconnected. It is never saved.
        Specified by:
        isTemp in interface Buddy
        Returns:
        true if the Buddy is temporary
      • setIsTemp

        public void setIsTemp​(boolean value)
        Specified by:
        setIsTemp in interface Buddy
      • setBlocked

        public void setBlocked​(boolean value)
        Description copied from interface: Buddy
        Block the Buddy
        Specified by:
        setBlocked in interface Buddy
        Parameters:
        value - true to block the buddy, false to unblock him
      • setVariable

        public void setVariable​(BuddyVariable buddyVariable)
        Description copied from interface: Buddy
        Set / modify a BuddyVariable.
        By convention any variables starting with a '$' (dollar sign) will be stored persistently when the use goes off-line
        Persistent variables are available even when the Buddy is not online.
        Specified by:
        setVariable in interface Buddy
        Parameters:
        buddyVariable - the Buddy Variable
      • setVariables

        public void setVariables​(java.util.List<BuddyVariable> buddyVariables)
        Description copied from interface: Buddy
        Sets a number of variables at once.
        Specified by:
        setVariables in interface Buddy
        Parameters:
        buddyVariables - a list of variables
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object