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 ISFSArraygetBuddyVariablesData()java.lang.StringgetName()The Buddy name, which corresponds to the User name.java.lang.StringgetNickName()Get the nickname of the Buddy.BuddyListgetParentBuddyList()Return the parent BuddyList containing this Buddyjava.lang.StringgetState()Returns the current Buddy StateBuddyVariablegetVariable(java.lang.String varName)Get a Buddy Variable from its namejava.util.List<BuddyVariable>getVariables()Get all BuddyVariablesbooleanhasVariables()Checks if the Buddy has at least one variable setbooleanisBlocked()When a Buddy is blocked he won't be able to see the User status and send him messagesbooleanisOnline()Checks if the Buddy is active in the systembooleanisTemp()A temporary Buddy will only exist at runtime but will be lost as soon as he goes away or the user is disconnected.voidsetBlocked(boolean value)Block the BuddyvoidsetIsTemp(boolean value)voidsetParentBuddyList(BuddyList parentList)Set the parent BuddyListvoidsetVariable(BuddyVariable buddyVariable)Set / modify a BuddyVariable.voidsetVariables(java.util.List<BuddyVariable> buddyVariables)Sets a number of variables at once.ISFSArraytoSFSArray()java.lang.StringtoString()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:BuddyThe Buddy name, which corresponds to the User name.
-
getParentBuddyList
public BuddyList getParentBuddyList()
Description copied from interface:BuddyReturn the parent BuddyList containing this Buddy- Specified by:
getParentBuddyListin interfaceBuddy- Returns:
- the parent BuddyList
-
setParentBuddyList
public void setParentBuddyList(BuddyList parentList)
Description copied from interface:BuddySet the parent BuddyList- Specified by:
setParentBuddyListin interfaceBuddy- Parameters:
parentList- the BuddyList
-
getState
public java.lang.String getState()
Description copied from interface:BuddyReturns the current Buddy State
-
getNickName
public java.lang.String getNickName()
Description copied from interface:BuddyGet the nickname of the Buddy. By default no Buddies have no nickname set- Specified by:
getNickNamein interfaceBuddy
-
hasVariables
public boolean hasVariables()
Description copied from interface:BuddyChecks if the Buddy has at least one variable set- Specified by:
hasVariablesin interfaceBuddy- Returns:
- true if at least 1 variable exists for this buddy
-
getVariable
public BuddyVariable getVariable(java.lang.String varName)
Description copied from interface:BuddyGet a Buddy Variable from its name- Specified by:
getVariablein 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:BuddyGet all BuddyVariables- Specified by:
getVariablesin interfaceBuddy- Returns:
- a List with all the BuddyVariables
-
isBlocked
public boolean isBlocked()
Description copied from interface:BuddyWhen 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:BuddyChecks if the Buddy is active in the system
-
isTemp
public boolean isTemp()
Description copied from interface:BuddyA 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:BuddyBlock the Buddy- Specified by:
setBlockedin interfaceBuddy- Parameters:
value- true to block the buddy, false to unblock him
-
setVariable
public void setVariable(BuddyVariable buddyVariable)
Description copied from interface:BuddySet / 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:
setVariablein interfaceBuddy- Parameters:
buddyVariable- the Buddy Variable
-
setVariables
public void setVariables(java.util.List<BuddyVariable> buddyVariables)
Description copied from interface:BuddySets a number of variables at once.- Specified by:
setVariablesin interfaceBuddy- Parameters:
buddyVariables- a list of variables
-
toSFSArray
public ISFSArray toSFSArray()
- Specified by:
toSFSArrayin interfaceBuddy
-
getBuddyVariablesData
public ISFSArray getBuddyVariablesData()
- Specified by:
getBuddyVariablesDatain interfaceBuddy
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-