Package com.smartfoxserver.v2.buddylist
Class SFSBuddy
- java.lang.Object
-
- com.smartfoxserver.v2.buddylist.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ISFSArray
getBuddyVariablesData()
java.lang.String
getName()
The Buddy name, which corresponds to the User name.java.lang.String
getNickName()
Get the nickname of the Buddy.BuddyList
getParentBuddyList()
Return the parent BuddyList containing this Buddyjava.lang.String
getState()
Returns the current Buddy StateBuddyVariable
getVariable(java.lang.String varName)
Get a Buddy Variable from its namejava.util.List<BuddyVariable>
getVariables()
Get all BuddyVariablesboolean
hasVariables()
Checks if the Buddy has at least one variable setboolean
isBlocked()
When a Buddy is blocked he won't be able to see the User status and send him messagesboolean
isOnline()
Checks if the Buddy is active in the systemboolean
isTemp()
A temporary Buddy will only exist at runtime but will be lost as soon as he goes away or the user is disconnected.void
setBlocked(boolean value)
Block the Buddyvoid
setIsTemp(boolean value)
void
setParentBuddyList(BuddyList parentList)
Set the parent BuddyListvoid
setVariable(BuddyVariable buddyVariable)
Set / modify a BuddyVariable.void
setVariables(java.util.List<BuddyVariable> buddyVariables)
Sets a number of variables at once.ISFSArray
toSFSArray()
java.lang.String
toString()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:Buddy
The Buddy name, which corresponds to the User name.
-
getParentBuddyList
public BuddyList getParentBuddyList()
Description copied from interface:Buddy
Return the parent BuddyList containing this Buddy- Specified by:
getParentBuddyList
in interfaceBuddy
- Returns:
- the parent BuddyList
-
setParentBuddyList
public void setParentBuddyList(BuddyList parentList)
Description copied from interface:Buddy
Set the parent BuddyList- Specified by:
setParentBuddyList
in interfaceBuddy
- Parameters:
parentList
- the BuddyList
-
getState
public java.lang.String getState()
Description copied from interface:Buddy
Returns the current Buddy State
-
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 interfaceBuddy
-
hasVariables
public boolean hasVariables()
Description copied from interface:Buddy
Checks if the Buddy has at least one variable set- Specified by:
hasVariables
in interfaceBuddy
- 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 interfaceBuddy
- 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 interfaceBuddy
- 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
-
isOnline
public boolean isOnline()
Description copied from interface:Buddy
Checks if the Buddy is active in the system
-
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.
-
setBlocked
public void setBlocked(boolean value)
Description copied from interface:Buddy
Block the Buddy- Specified by:
setBlocked
in interfaceBuddy
- 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 interfaceBuddy
- 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 interfaceBuddy
- Parameters:
buddyVariables
- a list of variables
-
toSFSArray
public ISFSArray toSFSArray()
- Specified by:
toSFSArray
in interfaceBuddy
-
getBuddyVariablesData
public ISFSArray getBuddyVariablesData()
- Specified by:
getBuddyVariablesData
in interfaceBuddy
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-