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.IService
init
in interface com.smartfoxserver.bitswarm.service.IService
o
- custom parameterspublic void destroy(java.lang.Object o)
com.smartfoxserver.bitswarm.service.IService
destroy
in interface com.smartfoxserver.bitswarm.service.IService
o
- custom parameterspublic java.lang.String getName()
com.smartfoxserver.bitswarm.service.IService
getName
in interface com.smartfoxserver.bitswarm.service.IService
public void setName(java.lang.String name)
com.smartfoxserver.bitswarm.service.IService
setName
in interface com.smartfoxserver.bitswarm.service.IService
name
- the service namepublic void handleMessage(java.lang.Object o)
com.smartfoxserver.bitswarm.service.IService
handleMessage
in interface com.smartfoxserver.bitswarm.service.IService
o
- the messagepublic Invitation findById(int id)
InvitationManager
findById
in interface InvitationManager
public int getMaxInvitationsPerUser()
getMaxInvitationsPerUser
in interface InvitationManager
public void setMaxInvitationsPerUser(int value)
setMaxInvitationsPerUser
in interface InvitationManager
value
- the max amount of invitations a User can run simultaneouslypublic void startInvitation(Invitation invitation, InvitationCallback callBack)
InvitationManager
startInvitation
in interface InvitationManager
invitation
- the invitation objectcallBack
- the response handlerprotected java.util.List<Invitation> prepareStartInvitation(Invitation invitation, InvitationCallback callBack)
public void suppressInvitation(Invitation invitation)
InvitationManager
suppressInvitation
in interface InvitationManager
invitation
- the invitationpublic void onInvitationResult(int invitationId, InvitationResponse result, ISFSObject params) throws SFSInvitationException
InvitationManager
onInvitationResult
in interface InvitationManager
invitationId
- the id of the invitationresult
- the resultparams
- optional paramsSFSInvitationException
public void onInvitationResult(Invitation invitation, InvitationResponse result, ISFSObject params) throws SFSInvitationException
InvitationManager
onInvitationResult
in interface InvitationManager
invitation
- the invitationresult
- the resultparams
- optional paramsSFSInvitationException
public IDGenerator getIDGenerator()
getIDGenerator
in interface InvitationManager
protected void initCleanUpTask()
protected void handleAcceptedInvitation(Invitation invitation, ISFSObject params)
protected void handleRefusedInvitation(Invitation invitation, ISFSObject params)
protected void removeInvitation(Invitation invitation)