Package com.smartfoxserver.v2.buddylist
Class SFSBuddyListManager
- java.lang.Object
 - 
- com.smartfoxserver.v2.buddylist.SFSBuddyListManager
 
 
- 
- All Implemented Interfaces:
 com.smartfoxserver.bitswarm.service.IService,BuddyListManager
public class SFSBuddyListManager extends java.lang.Object implements BuddyListManager
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected booleanactiveprotected ISFSBuddyApibuddyApiprotected java.util.Map<java.lang.String,BuddyList>buddyListsprotected java.util.List<java.lang.String>buddyStatesprotected BuddyStoragebuddyStorageprotected intbvCacheSizeprotected org.slf4j.Loggerlogprotected intmaxListSizeprotected intmaxVariablesprotected booleanofflineBuddyVariablesprotected com.smartfoxserver.v2.buddylist.cache.BuddyVariablesCacheofflineVarsCacheprotected java.lang.StringserviceNameprotected SmartFoxServersfsprotected booleanuseBadWordsFilterprotected ISFSEventListeneruserExitEventHandlerprotected booleanuseTempBuddiesprotected Zonezone 
- 
Constructor Summary
Constructors Constructor Description SFSBuddyListManager(Zone parentZone, boolean isActive) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuddyaddBuddy(java.lang.String ownerName, java.lang.String buddyName, boolean isTemp)Use the SFSBuddyAPIbooleanallowOfflineBuddyVariables()Check if the "offline" (persistent) Buddy Variables are supported in the current Zonevoiddestroy(java.lang.Object o)Destroy servicebooleangetApplyBadWordsFilter()Check if the current Zone applies the WordFilter to the Buddy messagesBuddyListgetBuddyList(java.lang.String ownerName)Get the Buddy List of a specific userintgetBuddyListMaxSize()Get the maximum size of a BuddyListjava.util.List<java.lang.String>getBuddyStates()Get a list of custom Buddy states such as "Available", "Occupied", "Be right back" etc...java.util.List<ISession>getClientsWatchingBuddy(java.lang.String buddyName)java.util.List<ISession>getClientsWatchingBuddy(java.lang.String buddyName, boolean onlineUsersOnly)intgetMaxBuddyVariables()Get the limit of BuddyVariables that each User can createjava.lang.StringgetName()Get the service nameBuddyVariablegetOfflineBuddyVariable(java.lang.String ownerName, java.lang.String varName)java.util.List<BuddyVariable>getOfflineBuddyVariables(java.lang.String ownerName)java.util.List<BuddyVariable>getOfflineBuddyVariables(java.lang.String ownerName, boolean bypassCache)intgetOfflineBuddyVariablesCacheSize()Get the size of the "offline" Buddy Variables cache.java.util.List<java.lang.String>getRecipientNamesForUpdate(java.lang.String owner)BuddyStoragegetStorageHandler()Get a reference to the instance of the BuddyStorage class, which handles the data persistencebooleangetUseTempBuddies()Check if the current Zone supports temporary BuddiesZonegetZone()Get the parent ZonevoidhandleMessage(java.lang.Object arg0)Send message to servicevoidinit(java.lang.Object o)Initialize servicebooleanisActive()Check if the BuddyList management is active in the ZoneBuddyListloadBuddyList(java.lang.String ownerName)Use the SFSBuddyAPIBuddyremoveBuddy(java.lang.String ownerName, java.lang.String buddyName)Use the SFSBuddyAPIvoidremoveBuddyList(java.lang.String ownerName)voidsaveAll()This is called automatically by the systemvoidsaveBuddyList(java.lang.String ownerName)This is called automatically by the systemvoidsetActive(boolean value)voidsetAllowOfflineBuddyVariables(boolean value)voidsetApplyBadWordsFilter(boolean value)voidsetBuddyListMaxSize(int maxSize)voidsetBuddyStates(java.util.List<java.lang.String> states)voidsetMaxBuddyVariables(int maxVariables)voidsetName(java.lang.String arg0)Set the service namevoidsetOfflineBuddyVariablesCacheSize(int size)voidsetStorageHandler(BuddyStorage buddyStorage)voidsetUseTempBuddies(boolean value) 
 - 
 
- 
- 
Field Detail
- 
log
protected final org.slf4j.Logger log
 
- 
zone
protected final Zone zone
 
- 
serviceName
protected final java.lang.String serviceName
 
- 
active
protected boolean active
 
- 
offlineBuddyVariables
protected boolean offlineBuddyVariables
 
- 
useTempBuddies
protected boolean useTempBuddies
 
- 
useBadWordsFilter
protected boolean useBadWordsFilter
 
- 
maxListSize
protected int maxListSize
 
- 
maxVariables
protected int maxVariables
 
- 
bvCacheSize
protected int bvCacheSize
 
- 
buddyStorage
protected BuddyStorage buddyStorage
 
- 
offlineVarsCache
protected com.smartfoxserver.v2.buddylist.cache.BuddyVariablesCache offlineVarsCache
 
- 
userExitEventHandler
protected final ISFSEventListener userExitEventHandler
 
- 
buddyLists
protected final java.util.Map<java.lang.String,BuddyList> buddyLists
 
- 
sfs
protected final SmartFoxServer sfs
 
- 
buddyApi
protected final ISFSBuddyApi buddyApi
 
- 
buddyStates
protected java.util.List<java.lang.String> buddyStates
 
 - 
 
- 
Constructor Detail
- 
SFSBuddyListManager
public SFSBuddyListManager(Zone parentZone, boolean isActive)
 
 - 
 
- 
Method Detail
- 
init
public void init(java.lang.Object o)
Initialize service- Specified by:
 initin interfacecom.smartfoxserver.bitswarm.service.IService- Parameters:
 o- custom parameters
 
- 
destroy
public void destroy(java.lang.Object o)
Destroy service- Specified by:
 destroyin interfacecom.smartfoxserver.bitswarm.service.IService- Parameters:
 o- custom parameters
 
- 
allowOfflineBuddyVariables
public boolean allowOfflineBuddyVariables()
Check if the "offline" (persistent) Buddy Variables are supported in the current Zone- Specified by:
 allowOfflineBuddyVariablesin interfaceBuddyListManager- Returns:
 - true if the "offline" (persistent) Buddy Variables are supported in the current Zone
 
 
- 
setAllowOfflineBuddyVariables
public void setAllowOfflineBuddyVariables(boolean value)
- Specified by:
 setAllowOfflineBuddyVariablesin interfaceBuddyListManager
 
- 
addBuddy
public Buddy addBuddy(java.lang.String ownerName, java.lang.String buddyName, boolean isTemp) throws SFSBuddyListException
Use the SFSBuddyAPI- Specified by:
 addBuddyin interfaceBuddyListManager- Throws:
 SFSBuddyListException- See Also:
 SFSBuddyApi.addBuddy(com.smartfoxserver.v2.entities.User, String, boolean, boolean, boolean)
 
- 
getBuddyList
public BuddyList getBuddyList(java.lang.String ownerName)
Get the Buddy List of a specific user- Specified by:
 getBuddyListin interfaceBuddyListManager- Parameters:
 ownerName- the user name- Returns:
 - the Buddy List
 
 
- 
getBuddyListMaxSize
public int getBuddyListMaxSize()
Get the maximum size of a BuddyList- Specified by:
 getBuddyListMaxSizein interfaceBuddyListManager- Returns:
 - the maximum size of a BuddyList
 
 
- 
getMaxBuddyVariables
public int getMaxBuddyVariables()
Get the limit of BuddyVariables that each User can create- Specified by:
 getMaxBuddyVariablesin interfaceBuddyListManager- Returns:
 - the limit of BuddyVariables that each User can create
 
 
- 
getStorageHandler
public BuddyStorage getStorageHandler()
Get a reference to the instance of the BuddyStorage class, which handles the data persistence- Specified by:
 getStorageHandlerin interfaceBuddyListManager- Returns:
 - a reference to the instance of the BuddyStorage class, which handles the data persistence
 
 
- 
getZone
public Zone getZone()
Get the parent Zone- Specified by:
 getZonein interfaceBuddyListManager- Returns:
 - the parent Zone
 
 
- 
isActive
public boolean isActive()
Check if the BuddyList management is active in the Zone- Specified by:
 isActivein interfaceBuddyListManager- Returns:
 - true if the BuddyList management is active in the Zone
 
 
- 
loadBuddyList
public BuddyList loadBuddyList(java.lang.String ownerName) throws java.io.IOException
Use the SFSBuddyAPI- Specified by:
 loadBuddyListin interfaceBuddyListManager- Throws:
 java.io.IOException- See Also:
 SFSBuddyApi.initBuddyList(com.smartfoxserver.v2.entities.User, boolean)
 
- 
removeBuddy
public Buddy removeBuddy(java.lang.String ownerName, java.lang.String buddyName)
Use the SFSBuddyAPI- Specified by:
 removeBuddyin interfaceBuddyListManager- See Also:
 SFSBuddyApi.removeBuddy(Zone, String, String, boolean, boolean)
 
- 
removeBuddyList
public void removeBuddyList(java.lang.String ownerName)
- Specified by:
 removeBuddyListin interfaceBuddyListManager
 
- 
saveAll
public void saveAll()
This is called automatically by the system- Specified by:
 saveAllin interfaceBuddyListManager
 
- 
saveBuddyList
public void saveBuddyList(java.lang.String ownerName) throws java.io.IOExceptionThis is called automatically by the system- Specified by:
 saveBuddyListin interfaceBuddyListManager- Throws:
 java.io.IOException
 
- 
getBuddyStates
public java.util.List<java.lang.String> getBuddyStates()
Get a list of custom Buddy states such as "Available", "Occupied", "Be right back" etc... These states are defined in the Zone configuration and are transmitted to the client upon Buddy List initialization.- Specified by:
 getBuddyStatesin interfaceBuddyListManager- Returns:
 - a list of custom Buddy states
 
 
- 
setBuddyStates
public void setBuddyStates(java.util.List<java.lang.String> states)
- Specified by:
 setBuddyStatesin interfaceBuddyListManager
 
- 
getApplyBadWordsFilter
public boolean getApplyBadWordsFilter()
Check if the current Zone applies the WordFilter to the Buddy messages- Specified by:
 getApplyBadWordsFilterin interfaceBuddyListManager- Returns:
 - true if the current Zone applies the WordFilter to the Buddy messages
 - See Also:
 SFSBuddyApi.sendBuddyMessage(com.smartfoxserver.v2.entities.User, com.smartfoxserver.v2.entities.User, String, com.smartfoxserver.v2.entities.data.ISFSObject)
 
- 
setApplyBadWordsFilter
public void setApplyBadWordsFilter(boolean value)
- Specified by:
 setApplyBadWordsFilterin interfaceBuddyListManager
 
- 
getOfflineBuddyVariable
public BuddyVariable getOfflineBuddyVariable(java.lang.String ownerName, java.lang.String varName)
- Specified by:
 getOfflineBuddyVariablein interfaceBuddyListManager
 
- 
getOfflineBuddyVariables
public java.util.List<BuddyVariable> getOfflineBuddyVariables(java.lang.String ownerName)
- Specified by:
 getOfflineBuddyVariablesin interfaceBuddyListManager
 
- 
getOfflineBuddyVariables
public java.util.List<BuddyVariable> getOfflineBuddyVariables(java.lang.String ownerName, boolean bypassCache)
- Specified by:
 getOfflineBuddyVariablesin interfaceBuddyListManager
 
- 
setActive
public void setActive(boolean value)
- Specified by:
 setActivein interfaceBuddyListManager
 
- 
setBuddyListMaxSize
public void setBuddyListMaxSize(int maxSize)
- Specified by:
 setBuddyListMaxSizein interfaceBuddyListManager
 
- 
setMaxBuddyVariables
public void setMaxBuddyVariables(int maxVariables)
- Specified by:
 setMaxBuddyVariablesin interfaceBuddyListManager
 
- 
getOfflineBuddyVariablesCacheSize
public int getOfflineBuddyVariablesCacheSize()
Get the size of the "offline" Buddy Variables cache.- Specified by:
 getOfflineBuddyVariablesCacheSizein interfaceBuddyListManager- Returns:
 - the size of the "offline" Buddy Variables cache.
 
 
- 
setOfflineBuddyVariablesCacheSize
public void setOfflineBuddyVariablesCacheSize(int size)
- Specified by:
 setOfflineBuddyVariablesCacheSizein interfaceBuddyListManager
 
- 
setStorageHandler
public void setStorageHandler(BuddyStorage buddyStorage)
- Specified by:
 setStorageHandlerin interfaceBuddyListManager
 
- 
getName
public java.lang.String getName()
Description copied from interface:com.smartfoxserver.bitswarm.service.IServiceGet the service name- Specified by:
 getNamein interfacecom.smartfoxserver.bitswarm.service.IService- Returns:
 - the service name
 
 
- 
handleMessage
public void handleMessage(java.lang.Object arg0) throws java.lang.ExceptionDescription copied from interface:com.smartfoxserver.bitswarm.service.IServiceSend message to service- Specified by:
 handleMessagein interfacecom.smartfoxserver.bitswarm.service.IService- Parameters:
 arg0- the message- Throws:
 java.lang.Exception
 
- 
setName
public void setName(java.lang.String arg0)
Description copied from interface:com.smartfoxserver.bitswarm.service.IServiceSet the service name- Specified by:
 setNamein interfacecom.smartfoxserver.bitswarm.service.IService- Parameters:
 arg0- the service name
 
- 
getUseTempBuddies
public boolean getUseTempBuddies()
Check if the current Zone supports temporary Buddies- Specified by:
 getUseTempBuddiesin interfaceBuddyListManager- Returns:
 - true if the current Zone supports temporary Buddies
 
 
- 
setUseTempBuddies
public void setUseTempBuddies(boolean value)
- Specified by:
 setUseTempBuddiesin interfaceBuddyListManager
 
- 
getClientsWatchingBuddy
public java.util.List<ISession> getClientsWatchingBuddy(java.lang.String buddyName)
- Specified by:
 getClientsWatchingBuddyin interfaceBuddyListManager
 
- 
getRecipientNamesForUpdate
public java.util.List<java.lang.String> getRecipientNamesForUpdate(java.lang.String owner)
- Specified by:
 getRecipientNamesForUpdatein interfaceBuddyListManager
 
- 
getClientsWatchingBuddy
public java.util.List<ISession> getClientsWatchingBuddy(java.lang.String buddyName, boolean onlineUsersOnly)
- Specified by:
 getClientsWatchingBuddyin interfaceBuddyListManager
 
 - 
 
 -