Package com.smartfoxserver.api
Class SFSBuddyApi
java.lang.Object
com.smartfoxserver.api.SFSBuddyApi
- All Implemented Interfaces:
ISFSBuddyApi
Provides access to the API for managing Buddies and Buddy lists.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.slf4j.Loggerprotected final com.smartfoxserver.api.ISFSBuddyResponseApiprotected final SmartFoxServerprotected final ISFSApi -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBuddy(User owner, String buddyName, boolean isTemp, boolean fireClientEvent, boolean fireServerEvent) Adds a new buddy to the BuddyList of the specified User.voidblockBuddy(User owner, 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 or send messages to that Usercom.smartfoxserver.api.ISFSBuddyResponseApivoidToggles the Buddy ONLINE state of the User.initBuddyList(User user, boolean fireServerEvent) Initializes the buddy list for the requested User.protected voidinitializeBuddyState(User user) voidremoveBuddy(User owner, String buddyName, boolean fireClientEvent, boolean fireServerEvent) Remove a Buddy from the owner's BuddyListvoidsendBuddyMessage(User sender, User recipient, String message, ISFSObject params) Send a Buddy Message to any Buddy in your list.voidsetBuddyVariables(User owner, List<BuddyVariable> buddyVariables, boolean fireClientEvent, boolean fireServerEvent) Set any number of BuddyVariables for the specified owner
-
Field Details
-
sfs
-
log
protected final org.slf4j.Logger log -
responseAPI
protected final com.smartfoxserver.api.ISFSBuddyResponseApi responseAPI -
sfsApi
-
-
Constructor Details
-
SFSBuddyApi
-
-
Method Details
-
getResponseAPI
public com.smartfoxserver.api.ISFSBuddyResponseApi getResponseAPI()- Specified by:
getResponseAPIin interfaceISFSBuddyApi
-
initBuddyList
Initializes the buddy list for the requested User. This involves loading previous data from the BuddyList storage.- Specified by:
initBuddyListin interfaceISFSBuddyApi- Parameters:
user- the UserfireServerEvent- if true fires a server side event (BUDDY_LIST_INIT)- Returns:
- the loaded BuddyList
- Throws:
IOException
-
goOnline
Toggles the Buddy ONLINE state of the User. All clients who have this User as their Buddy will be notified about the change.- Specified by:
goOnlinein interfaceISFSBuddyApi- Parameters:
user- the Useronline- the online statusfireServerEvent- if true fires a server side event (BUDDY_ONLINE)
-
addBuddy
public void addBuddy(User owner, String buddyName, boolean isTemp, boolean fireClientEvent, boolean fireServerEvent) throws SFSBuddyListException Adds a new buddy to the BuddyList of the specified User.- Specified by:
addBuddyin 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
-
removeBuddy
public void removeBuddy(User owner, String buddyName, boolean fireClientEvent, boolean fireServerEvent) Remove a Buddy from the owner's BuddyList- Specified by:
removeBuddyin interfaceISFSBuddyApi- Parameters:
owner- the ownerbuddyName- the Buddy namefireClientEvent- if true send a client updatefireServerEvent- if true fire a server side event (BUDDY_REMOVED)
-
blockBuddy
public void blockBuddy(User owner, 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 or send messages to that User- Specified by:
blockBuddyin 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, List<BuddyVariable> buddyVariables, boolean fireClientEvent, boolean fireServerEvent) throws SFSBuddyListException Set any number of BuddyVariables for the specified owner- Specified by:
setBuddyVariablesin 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, String message, ISFSObject params) throws SFSBuddyListException Send a Buddy Message to any Buddy in your list. A Buddy message is similar to a Private Message but it is meant to work with the BuddyList taking into account the Buddy states (online/offline/blocked etc.)- Specified by:
sendBuddyMessagein 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
- Throws:
SFSBuddyListException
-