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 boolean
active
protected ISFSBuddyApi
buddyApi
protected java.util.Map<java.lang.String,BuddyList>
buddyLists
protected java.util.List<java.lang.String>
buddyStates
protected BuddyStorage
buddyStorage
protected int
bvCacheSize
protected org.slf4j.Logger
log
protected int
maxListSize
protected int
maxVariables
protected boolean
offlineBuddyVariables
protected com.smartfoxserver.v2.buddylist.cache.BuddyVariablesCache
offlineVarsCache
protected java.lang.String
serviceName
protected SmartFoxServer
sfs
protected boolean
useBadWordsFilter
protected ISFSEventListener
userExitEventHandler
protected boolean
useTempBuddies
protected Zone
zone
-
Constructor Summary
Constructors Constructor Description SFSBuddyListManager(Zone parentZone, boolean isActive)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Buddy
addBuddy(java.lang.String ownerName, java.lang.String buddyName, boolean isTemp)
Use the SFSBuddyAPIboolean
allowOfflineBuddyVariables()
Check if the "offline" (persistent) Buddy Variables are supported in the current Zonevoid
destroy(java.lang.Object o)
Destroy serviceboolean
getApplyBadWordsFilter()
Check if the current Zone applies the WordFilter to the Buddy messagesBuddyList
getBuddyList(java.lang.String ownerName)
Get the Buddy List of a specific userint
getBuddyListMaxSize()
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)
int
getMaxBuddyVariables()
Get the limit of BuddyVariables that each User can createjava.lang.String
getName()
Get the service nameBuddyVariable
getOfflineBuddyVariable(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)
int
getOfflineBuddyVariablesCacheSize()
Get the size of the "offline" Buddy Variables cache.java.util.List<java.lang.String>
getRecipientNamesForUpdate(java.lang.String owner)
BuddyStorage
getStorageHandler()
Get a reference to the instance of the BuddyStorage class, which handles the data persistenceboolean
getUseTempBuddies()
Check if the current Zone supports temporary BuddiesZone
getZone()
Get the parent Zonevoid
handleMessage(java.lang.Object arg0)
Send message to servicevoid
init(java.lang.Object o)
Initialize serviceboolean
isActive()
Check if the BuddyList management is active in the ZoneBuddyList
loadBuddyList(java.lang.String ownerName)
Use the SFSBuddyAPIBuddy
removeBuddy(java.lang.String ownerName, java.lang.String buddyName)
Use the SFSBuddyAPIvoid
removeBuddyList(java.lang.String ownerName)
void
saveAll()
This is called automatically by the systemvoid
saveBuddyList(java.lang.String ownerName)
This is called automatically by the systemvoid
setActive(boolean value)
void
setAllowOfflineBuddyVariables(boolean value)
void
setApplyBadWordsFilter(boolean value)
void
setBuddyListMaxSize(int maxSize)
void
setBuddyStates(java.util.List<java.lang.String> states)
void
setMaxBuddyVariables(int maxVariables)
void
setName(java.lang.String arg0)
Set the service namevoid
setOfflineBuddyVariablesCacheSize(int size)
void
setStorageHandler(BuddyStorage buddyStorage)
void
setUseTempBuddies(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:
init
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
o
- custom parameters
-
destroy
public void destroy(java.lang.Object o)
Destroy service- Specified by:
destroy
in 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:
allowOfflineBuddyVariables
in interfaceBuddyListManager
- Returns:
- true if the "offline" (persistent) Buddy Variables are supported in the current Zone
-
setAllowOfflineBuddyVariables
public void setAllowOfflineBuddyVariables(boolean value)
- Specified by:
setAllowOfflineBuddyVariables
in interfaceBuddyListManager
-
addBuddy
public Buddy addBuddy(java.lang.String ownerName, java.lang.String buddyName, boolean isTemp) throws SFSBuddyListException
Use the SFSBuddyAPI- Specified by:
addBuddy
in 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:
getBuddyList
in interfaceBuddyListManager
- Parameters:
ownerName
- the user name- Returns:
- the Buddy List
-
getBuddyListMaxSize
public int getBuddyListMaxSize()
Get the maximum size of a BuddyList- Specified by:
getBuddyListMaxSize
in interfaceBuddyListManager
- Returns:
- the maximum size of a BuddyList
-
getMaxBuddyVariables
public int getMaxBuddyVariables()
Get the limit of BuddyVariables that each User can create- Specified by:
getMaxBuddyVariables
in 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:
getStorageHandler
in 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:
getZone
in interfaceBuddyListManager
- Returns:
- the parent Zone
-
isActive
public boolean isActive()
Check if the BuddyList management is active in the Zone- Specified by:
isActive
in 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:
loadBuddyList
in 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:
removeBuddy
in interfaceBuddyListManager
- See Also:
SFSBuddyApi.removeBuddy(Zone, String, String, boolean, boolean)
-
removeBuddyList
public void removeBuddyList(java.lang.String ownerName)
- Specified by:
removeBuddyList
in interfaceBuddyListManager
-
saveAll
public void saveAll()
This is called automatically by the system- Specified by:
saveAll
in interfaceBuddyListManager
-
saveBuddyList
public void saveBuddyList(java.lang.String ownerName) throws java.io.IOException
This is called automatically by the system- Specified by:
saveBuddyList
in 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:
getBuddyStates
in interfaceBuddyListManager
- Returns:
- a list of custom Buddy states
-
setBuddyStates
public void setBuddyStates(java.util.List<java.lang.String> states)
- Specified by:
setBuddyStates
in interfaceBuddyListManager
-
getApplyBadWordsFilter
public boolean getApplyBadWordsFilter()
Check if the current Zone applies the WordFilter to the Buddy messages- Specified by:
getApplyBadWordsFilter
in 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:
setApplyBadWordsFilter
in interfaceBuddyListManager
-
getOfflineBuddyVariable
public BuddyVariable getOfflineBuddyVariable(java.lang.String ownerName, java.lang.String varName)
- Specified by:
getOfflineBuddyVariable
in interfaceBuddyListManager
-
getOfflineBuddyVariables
public java.util.List<BuddyVariable> getOfflineBuddyVariables(java.lang.String ownerName)
- Specified by:
getOfflineBuddyVariables
in interfaceBuddyListManager
-
getOfflineBuddyVariables
public java.util.List<BuddyVariable> getOfflineBuddyVariables(java.lang.String ownerName, boolean bypassCache)
- Specified by:
getOfflineBuddyVariables
in interfaceBuddyListManager
-
setActive
public void setActive(boolean value)
- Specified by:
setActive
in interfaceBuddyListManager
-
setBuddyListMaxSize
public void setBuddyListMaxSize(int maxSize)
- Specified by:
setBuddyListMaxSize
in interfaceBuddyListManager
-
setMaxBuddyVariables
public void setMaxBuddyVariables(int maxVariables)
- Specified by:
setMaxBuddyVariables
in interfaceBuddyListManager
-
getOfflineBuddyVariablesCacheSize
public int getOfflineBuddyVariablesCacheSize()
Get the size of the "offline" Buddy Variables cache.- Specified by:
getOfflineBuddyVariablesCacheSize
in interfaceBuddyListManager
- Returns:
- the size of the "offline" Buddy Variables cache.
-
setOfflineBuddyVariablesCacheSize
public void setOfflineBuddyVariablesCacheSize(int size)
- Specified by:
setOfflineBuddyVariablesCacheSize
in interfaceBuddyListManager
-
setStorageHandler
public void setStorageHandler(BuddyStorage buddyStorage)
- Specified by:
setStorageHandler
in interfaceBuddyListManager
-
getName
public java.lang.String getName()
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Get the service name- Specified by:
getName
in interfacecom.smartfoxserver.bitswarm.service.IService
- Returns:
- the service name
-
handleMessage
public void handleMessage(java.lang.Object arg0) throws java.lang.Exception
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Send message to service- Specified by:
handleMessage
in 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.IService
Set the service name- Specified by:
setName
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
arg0
- the service name
-
getUseTempBuddies
public boolean getUseTempBuddies()
Check if the current Zone supports temporary Buddies- Specified by:
getUseTempBuddies
in interfaceBuddyListManager
- Returns:
- true if the current Zone supports temporary Buddies
-
setUseTempBuddies
public void setUseTempBuddies(boolean value)
- Specified by:
setUseTempBuddies
in interfaceBuddyListManager
-
getClientsWatchingBuddy
public java.util.List<ISession> getClientsWatchingBuddy(java.lang.String buddyName)
- Specified by:
getClientsWatchingBuddy
in interfaceBuddyListManager
-
getRecipientNamesForUpdate
public java.util.List<java.lang.String> getRecipientNamesForUpdate(java.lang.String owner)
- Specified by:
getRecipientNamesForUpdate
in interfaceBuddyListManager
-
getClientsWatchingBuddy
public java.util.List<ISession> getClientsWatchingBuddy(java.lang.String buddyName, boolean onlineUsersOnly)
- Specified by:
getClientsWatchingBuddy
in interfaceBuddyListManager
-
-