Class SFSInvitationManager
- java.lang.Object
-
- com.smartfoxserver.v2.entities.invitation.SFSInvitationManager
-
- All Implemented Interfaces:
com.smartfoxserver.bitswarm.service.IService
,InvitationManager
public class SFSInvitationManager extends java.lang.Object implements com.smartfoxserver.bitswarm.service.IService, InvitationManager
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description SFSInvitationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy(java.lang.Object o)
Destroy serviceInvitation
findById(int id)
Find an invitation from its idIDGenerator
getIDGenerator()
int
getMaxInvitationsPerUser()
java.lang.String
getName()
Get the service nameprotected void
handleAcceptedInvitation(Invitation invitation, ISFSObject params)
void
handleMessage(java.lang.Object o)
Send message to serviceprotected void
handleRefusedInvitation(Invitation invitation, ISFSObject params)
void
init(java.lang.Object o)
Initialize serviceprotected void
initCleanUpTask()
void
onInvitationResult(int invitationId, InvitationResponse result, ISFSObject params)
Handle the response to an invitationvoid
onInvitationResult(Invitation invitation, InvitationResponse result, ISFSObject params)
Handle the response to an invitationprotected 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 namevoid
startInvitation(Invitation invitation, InvitationCallback callBack)
Start a new invitationvoid
suppressInvitation(Invitation invitation)
Stop an invitation that is running
-
-
-
Field Detail
-
serviceName
protected java.lang.String serviceName
-
sfs
protected final SmartFoxServer sfs
-
log
protected final org.slf4j.Logger log
-
invitationsById
protected final java.util.Map<java.lang.Integer,Invitation> invitationsById
-
invitationsByOwner
protected final java.util.Map<User,java.util.List<Invitation>> invitationsByOwner
-
maxInvitationsPerUser
protected int maxInvitationsPerUser
-
idGen
protected IDGenerator idGen
-
-
Method Detail
-
init
public void init(java.lang.Object o)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Initialize service- Specified by:
init
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
o
- custom parameters
-
destroy
public void destroy(java.lang.Object o)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Destroy service- Specified by:
destroy
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
o
- custom parameters
-
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
-
setName
public void setName(java.lang.String name)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Set the service name- Specified by:
setName
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
name
- the service name
-
handleMessage
public void handleMessage(java.lang.Object o)
Description copied from interface:com.smartfoxserver.bitswarm.service.IService
Send message to service- Specified by:
handleMessage
in interfacecom.smartfoxserver.bitswarm.service.IService
- Parameters:
o
- the message
-
findById
public Invitation findById(int id)
Description copied from interface:InvitationManager
Find an invitation from its id- Specified by:
findById
in interfaceInvitationManager
- Returns:
- the invitation object
-
getMaxInvitationsPerUser
public int getMaxInvitationsPerUser()
- Specified by:
getMaxInvitationsPerUser
in interfaceInvitationManager
- Returns:
- the max amount of invitations a User can run simultaneously
-
setMaxInvitationsPerUser
public void setMaxInvitationsPerUser(int value)
- Specified by:
setMaxInvitationsPerUser
in interfaceInvitationManager
- Parameters:
value
- the max amount of invitations a User can run simultaneously
-
startInvitation
public void startInvitation(Invitation invitation, InvitationCallback callBack)
Description copied from interface:InvitationManager
Start a new invitation- Specified by:
startInvitation
in interfaceInvitationManager
- Parameters:
invitation
- the invitation objectcallBack
- the response handler
-
prepareStartInvitation
protected java.util.List<Invitation> prepareStartInvitation(Invitation invitation, InvitationCallback callBack)
-
suppressInvitation
public void suppressInvitation(Invitation invitation)
Description copied from interface:InvitationManager
Stop an invitation that is running- Specified by:
suppressInvitation
in interfaceInvitationManager
- Parameters:
invitation
- the invitation
-
onInvitationResult
public void onInvitationResult(int invitationId, InvitationResponse result, ISFSObject params) throws SFSInvitationException
Description copied from interface:InvitationManager
Handle the response to an invitation- Specified by:
onInvitationResult
in interfaceInvitationManager
- Parameters:
invitationId
- the id of the invitationresult
- the resultparams
- optional params- Throws:
SFSInvitationException
-
onInvitationResult
public void onInvitationResult(Invitation invitation, InvitationResponse result, ISFSObject params) throws SFSInvitationException
Description copied from interface:InvitationManager
Handle the response to an invitation- Specified by:
onInvitationResult
in interfaceInvitationManager
- Parameters:
invitation
- the invitationresult
- the resultparams
- optional params- Throws:
SFSInvitationException
-
getIDGenerator
public IDGenerator getIDGenerator()
- Specified by:
getIDGenerator
in interfaceInvitationManager
-
initCleanUpTask
protected void initCleanUpTask()
-
handleAcceptedInvitation
protected void handleAcceptedInvitation(Invitation invitation, ISFSObject params)
-
handleRefusedInvitation
protected void handleRefusedInvitation(Invitation invitation, ISFSObject params)
-
removeInvitation
protected void removeInvitation(Invitation invitation)
-
-