public class SFSInvitationManager extends java.lang.Object implements com.smartfoxserver.bitswarm.service.IService, InvitationManager
| Modifier and Type | Field and Description |
|---|---|
protected IDGenerator |
idGen |
protected java.util.Map<java.lang.Integer,Invitation> |
invitationsById |
protected java.util.Map<User,java.util.List<Invitation>> |
invitationsByOwner |
protected org.slf4j.Logger |
log |
protected int |
maxInvitationsPerUser |
protected java.lang.String |
serviceName |
protected SmartFoxServer |
sfs |
| Constructor and Description |
|---|
SFSInvitationManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy(java.lang.Object o)
Destroy service
|
Invitation |
findById(int id)
Find an invitation from its id
|
IDGenerator |
getIDGenerator() |
int |
getMaxInvitationsPerUser() |
java.lang.String |
getName()
Get the service name
|
protected void |
handleAcceptedInvitation(Invitation invitation,
ISFSObject params) |
void |
handleMessage(java.lang.Object o)
Send message to service
|
protected void |
handleRefusedInvitation(Invitation invitation,
ISFSObject params) |
void |
init(java.lang.Object o)
Initialize service
|
protected void |
initCleanUpTask() |
void |
onInvitationResult(int invitationId,
InvitationResponse result,
ISFSObject params)
Handle the response to an invitation
|
void |
onInvitationResult(Invitation invitation,
InvitationResponse result,
ISFSObject params)
Handle the response to an invitation
|
protected java.util.List<Invitation> |
prepareStartInvitation(Invitation invitation,
InvitationCallback callBack) |
protected void |
removeInvitation(Invitation invitation) |
void |
setMaxInvitationsPerUser(int value) |
void |
setName(java.lang.String name)
Set the service name
|
void |
startInvitation(Invitation invitation,
InvitationCallback callBack)
Start a new invitation
|
void |
suppressInvitation(Invitation invitation)
Stop an invitation that is running
|
protected java.lang.String serviceName
protected final SmartFoxServer sfs
protected final org.slf4j.Logger log
protected final java.util.Map<java.lang.Integer,Invitation> invitationsById
protected final java.util.Map<User,java.util.List<Invitation>> invitationsByOwner
protected int maxInvitationsPerUser
protected IDGenerator idGen
public void init(java.lang.Object o)
com.smartfoxserver.bitswarm.service.IServiceinit in interface com.smartfoxserver.bitswarm.service.IServiceo - custom parameterspublic void destroy(java.lang.Object o)
com.smartfoxserver.bitswarm.service.IServicedestroy in interface com.smartfoxserver.bitswarm.service.IServiceo - custom parameterspublic java.lang.String getName()
com.smartfoxserver.bitswarm.service.IServicegetName in interface com.smartfoxserver.bitswarm.service.IServicepublic void setName(java.lang.String name)
com.smartfoxserver.bitswarm.service.IServicesetName in interface com.smartfoxserver.bitswarm.service.IServicename - the service namepublic void handleMessage(java.lang.Object o)
com.smartfoxserver.bitswarm.service.IServicehandleMessage in interface com.smartfoxserver.bitswarm.service.IServiceo - the messagepublic Invitation findById(int id)
InvitationManagerfindById in interface InvitationManagerpublic int getMaxInvitationsPerUser()
getMaxInvitationsPerUser in interface InvitationManagerpublic void setMaxInvitationsPerUser(int value)
setMaxInvitationsPerUser in interface InvitationManagervalue - the max amount of invitations a User can run simultaneouslypublic void startInvitation(Invitation invitation, InvitationCallback callBack)
InvitationManagerstartInvitation in interface InvitationManagerinvitation - the invitation objectcallBack - the response handlerprotected java.util.List<Invitation> prepareStartInvitation(Invitation invitation, InvitationCallback callBack)
public void suppressInvitation(Invitation invitation)
InvitationManagersuppressInvitation in interface InvitationManagerinvitation - the invitationpublic void onInvitationResult(int invitationId,
InvitationResponse result,
ISFSObject params)
throws SFSInvitationException
InvitationManageronInvitationResult in interface InvitationManagerinvitationId - the id of the invitationresult - the resultparams - optional paramsSFSInvitationExceptionpublic void onInvitationResult(Invitation invitation, InvitationResponse result, ISFSObject params) throws SFSInvitationException
InvitationManageronInvitationResult in interface InvitationManagerinvitation - the invitationresult - the resultparams - optional paramsSFSInvitationExceptionpublic IDGenerator getIDGenerator()
getIDGenerator in interface InvitationManagerprotected void initCleanUpTask()
protected void handleAcceptedInvitation(Invitation invitation, ISFSObject params)
protected void handleRefusedInvitation(Invitation invitation, ISFSObject params)
protected void removeInvitation(Invitation invitation)