Package com.smartfoxserver.v2.api
Class SFSBuddyApi
- java.lang.Object
-
- com.smartfoxserver.v2.api.SFSBuddyApi
-
- All Implemented Interfaces:
ISFSBuddyApi
public class SFSBuddyApi extends java.lang.Object implements ISFSBuddyApi
Provides all necessary functionalities for managing User buddy lists.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
log
protected com.smartfoxserver.v2.api.ISFSBuddyResponseApi
responseAPI
protected SmartFoxServer
sfs
protected ISFSApi
sfsApi
-
Constructor Summary
Constructors Constructor Description SFSBuddyApi(SmartFoxServer sfs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBuddy(User owner, java.lang.String buddyName, boolean isTemp, boolean fireClientEvent, boolean fireServerEvent)
Adds a new buddy to the BuddyList of the specified User.void
addBuddy(Zone zone, java.lang.String ownerName, java.lang.String buddyName, boolean isTemp, boolean fireClientEvent, boolean fireServerEvent)
Adds a buddy to the User's buddy list even if the User is not online at the moment This feature is not implemented yet.void
blockBuddy(User owner, java.lang.String buddyName, boolean isBlocked, boolean fireClientEvent, boolean fireServerEvent)
Block/Unblock a Buddy in the owner's BuddyList Blocked buddies won't be able to see the owner online status and send him messages or updatescom.smartfoxserver.v2.api.ISFSBuddyResponseApi
getResponseAPI()
void
goOnline(User user, boolean online, boolean fireServerEvent)
Activates/De-activates the Buddy ONLINE status of the User.BuddyList
initBuddyList(User user, boolean fireServerEvent)
Initialize the buddy list for the requested User.protected void
initializeBuddyState(User user)
void
removeBuddy(User owner, java.lang.String buddyName, boolean fireClientEvent, boolean fireServerEvent)
Remove a Buddy from the owner's BuddyListvoid
removeBuddy(Zone zone, java.lang.String ownerName, java.lang.String buddyName, boolean fireClientEvent, boolean fireServerEvent)
Removes a Buddy from the owner's BuddyList even if the User is not online at the moment This feature is not implemented yet.void
sendBuddyMessage(User sender, User recipient, java.lang.String message, ISFSObject params)
Send a Buddy Message to any Buddy in your list.void
setBuddyVariables(User owner, java.util.List<BuddyVariable> buddyVariables, boolean fireClientEvent, boolean fireServerEvent)
Set any number of BuddyVariables for the specified owner
-
-
-
Field Detail
-
sfs
protected final SmartFoxServer sfs
-
log
protected final org.slf4j.Logger log
-
responseAPI
protected final com.smartfoxserver.v2.api.ISFSBuddyResponseApi responseAPI
-
sfsApi
protected final ISFSApi sfsApi
-
-
Constructor Detail
-
SFSBuddyApi
public SFSBuddyApi(SmartFoxServer sfs)
-
-
Method Detail
-
getResponseAPI
public com.smartfoxserver.v2.api.ISFSBuddyResponseApi getResponseAPI()
- Specified by:
getResponseAPI
in interfaceISFSBuddyApi
-
initBuddyList
public BuddyList initBuddyList(User user, boolean fireServerEvent) throws java.io.IOException
Initialize the buddy list for the requested User. This involves loading previous data from the BuddyList storage.- Specified by:
initBuddyList
in interfaceISFSBuddyApi
- Parameters:
user
- the UserfireServerEvent
- if true fires a server side event (BUDDY_LIST_INIT)- Returns:
- the loaded BuddyList
- Throws:
java.io.IOException
-
goOnline
public void goOnline(User user, boolean online, boolean fireServerEvent)
Activates/De-activates the Buddy ONLINE status of the User. All clients who have the User as their Buddy will see him as online.- Specified by:
goOnline
in interfaceISFSBuddyApi
- Parameters:
user
- the Useronline
- the online statusfireServerEvent
- if true fires a server side event (BUDDY_ONLINE)
-
addBuddy
public void addBuddy(User owner, java.lang.String buddyName, boolean isTemp, boolean fireClientEvent, boolean fireServerEvent) throws SFSBuddyListException
Adds a new buddy to the BuddyList of the specified User.- Specified by:
addBuddy
in interfaceISFSBuddyApi
- Parameters:
owner
- the owner UserbuddyName
- the name of the buddy to addisTemp
- if true, the Buddy is only temporary and will be lost when the user logs outfireClientEvent
- if true, send a client updatefireServerEvent
- if true, fire a server event (BUDDY_ADDED)- Throws:
SFSBuddyListException
- an error might occur if the BuddyList is full or the buddy was already added
-
addBuddy
public void addBuddy(Zone zone, java.lang.String ownerName, java.lang.String buddyName, boolean isTemp, boolean fireClientEvent, boolean fireServerEvent) throws SFSBuddyListException
Adds a buddy to the User's buddy list even if the User is not online at the moment This feature is not implemented yet.- Specified by:
addBuddy
in interfaceISFSBuddyApi
- Throws:
SFSBuddyListException
-
removeBuddy
public void removeBuddy(User owner, java.lang.String buddyName, boolean fireClientEvent, boolean fireServerEvent)
Remove a Buddy from the owner's BuddyList- Specified by:
removeBuddy
in interfaceISFSBuddyApi
- Parameters:
owner
- the ownerbuddyName
- the Buddy namefireClientEvent
- if true send a client updatefireServerEvent
- if true fire a server side event (BUDDY_REMOVED)
-
removeBuddy
public void removeBuddy(Zone zone, java.lang.String ownerName, java.lang.String buddyName, boolean fireClientEvent, boolean fireServerEvent)
Description copied from interface:ISFSBuddyApi
Removes a Buddy from the owner's BuddyList even if the User is not online at the moment This feature is not implemented yet.- Specified by:
removeBuddy
in interfaceISFSBuddyApi
-
blockBuddy
public void blockBuddy(User owner, java.lang.String buddyName, boolean isBlocked, boolean fireClientEvent, boolean fireServerEvent)
Block/Unblock a Buddy in the owner's BuddyList Blocked buddies won't be able to see the owner online status and send him messages or updates- Specified by:
blockBuddy
in interfaceISFSBuddyApi
- Parameters:
owner
- the BuddyList ownerbuddyName
- the name of the Buddy to block/unblockisBlocked
- the 'blocked' flagfireClientEvent
- if true send a client updatefireServerEvent
- if true fire a server side event (BUDDY_BLOCK_UPDATE)
-
setBuddyVariables
public void setBuddyVariables(User owner, java.util.List<BuddyVariable> buddyVariables, boolean fireClientEvent, boolean fireServerEvent) throws SFSBuddyListException
Set any number of BuddyVariables for the specified owner- Specified by:
setBuddyVariables
in interfaceISFSBuddyApi
- Parameters:
owner
- the owner UserbuddyVariables
- a list of variablesfireClientEvent
- if true, send a client updatefireServerEvent
- if true, fire a server event (BUDDY_VARIABLES_UPDATE)- Throws:
SFSBuddyListException
- an error might occur if the limit of variables allowed is exceeded
-
sendBuddyMessage
public void sendBuddyMessage(User sender, User recipient, java.lang.String message, ISFSObject params) throws SFSBuddyListException
Send a Buddy Message to any Buddy in your list. A Buddy message is similar to a regular chat Private Message but it is meant to work with the BuddyList taking into account the Buddy blocked state etc...- Specified by:
sendBuddyMessage
in interfaceISFSBuddyApi
- Parameters:
sender
- the sender of the messagerecipient
- the recipient of the message (must be a Buddy in the sender's BuddyList)message
- the messageparams
- custom parameters- Throws:
SFSBuddyListException
- thrown if the Buddy is not in the sender's Buddy List or if the recipient has blocked the sender
-
initializeBuddyState
protected void initializeBuddyState(User user) throws SFSBuddyListException
- Throws:
SFSBuddyListException
-
-