Package com.tenio.engine.heartbeat
Class HeartBeatManager
- java.lang.Object
-
- com.tenio.logger.AbstractLogger
-
- com.tenio.engine.heartbeat.HeartBeatManager
-
- All Implemented Interfaces:
IHeartBeatManager
public final class HeartBeatManager extends AbstractLogger implements IHeartBeatManager
The Java ExecutorService is a construct that allows you to pass a task to be executed by a thread asynchronously. The executor service creates and maintains a reusable pool of threads for executing submitted tasks. This class helps you create and manage your HeartBeats. See:AbstractHeartBeat
- Author:
- kong
- See Also:
IHeartBeatManager
-
-
Constructor Summary
Constructors Constructor Description HeartBeatManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Destroy all heart-beats and clear all references.boolean
contains(java.lang.String id)
Check if a heart-beat is existed or not.void
create(java.lang.String id, AbstractHeartBeat heartbeat)
Create a new heart-beat.void
dispose(java.lang.String id)
Dispose a heart-beat.void
initialize(int maxHeartbeat)
The number of maximum heart-beats that the server can handle.void
initialize(BaseConfiguration configuration)
The number of maximum heart-beats that the server can handle.void
sendMessage(java.lang.String id, TObject message)
Send a message to a particular heart-beat with no delay timevoid
sendMessage(java.lang.String id, TObject message, double delayTime)
Send a message to a particular heart-beat with a delay time
-
-
-
Method Detail
-
initialize
public void initialize(BaseConfiguration configuration)
Description copied from interface:IHeartBeatManager
The number of maximum heart-beats that the server can handle.- Specified by:
initialize
in interfaceIHeartBeatManager
- Parameters:
configuration
- seeBaseConfiguration
-
initialize
public void initialize(int maxHeartbeat)
Description copied from interface:IHeartBeatManager
The number of maximum heart-beats that the server can handle.- Specified by:
initialize
in interfaceIHeartBeatManager
- Parameters:
maxHeartbeat
- the number of maximum heart-beats that the server can handle
-
create
public void create(java.lang.String id, AbstractHeartBeat heartbeat)
Description copied from interface:IHeartBeatManager
Create a new heart-beat.- Specified by:
create
in interfaceIHeartBeatManager
- Parameters:
id
- the unique idheartbeat
- seeAbstractHeartBeat
-
dispose
public void dispose(java.lang.String id)
Description copied from interface:IHeartBeatManager
Dispose a heart-beat.- Specified by:
dispose
in interfaceIHeartBeatManager
- Parameters:
id
- the unique id
-
contains
public boolean contains(java.lang.String id)
Description copied from interface:IHeartBeatManager
Check if a heart-beat is existed or not.- Specified by:
contains
in interfaceIHeartBeatManager
- Parameters:
id
- the unique id- Returns:
- true if the corresponding heart-beat has existed
-
clear
public void clear()
Description copied from interface:IHeartBeatManager
Destroy all heart-beats and clear all references.- Specified by:
clear
in interfaceIHeartBeatManager
-
sendMessage
public void sendMessage(java.lang.String id, TObject message, double delayTime)
Description copied from interface:IHeartBeatManager
Send a message to a particular heart-beat with a delay time- Specified by:
sendMessage
in interfaceIHeartBeatManager
- Parameters:
id
- the unique idmessage
- the message content, seeTObject
delayTime
- the delay time in seconds
-
sendMessage
public void sendMessage(java.lang.String id, TObject message)
Description copied from interface:IHeartBeatManager
Send a message to a particular heart-beat with no delay time- Specified by:
sendMessage
in interfaceIHeartBeatManager
- Parameters:
id
- the unique idmessage
- the message content, seeTObject
-
-