public class HeartbeatHandler extends AbstractDatagramHandler
Constructor and Description |
---|
HeartbeatHandler(ITimer timer,
long beatPeriod,
long downPeriod) |
HeartbeatHandler(SocketAddress remoteAddress,
ITimer timer,
long beatPeriod,
long downPeriod) |
Modifier and Type | Method and Description |
---|---|
void |
event(SessionEvent event)
Called to notify about a change of the associated session state.
|
ISessionConfig |
getConfig()
Returns the configuration object that will be used to configure the
behavior of the associated session.
|
ISessionStructureFactory |
getFactory()
Returns the factory object that will be used to configure the internal
structure of the associated session.
|
void |
read(byte[] data)
Called when new bytes were read from the input buffer.
|
void |
read(Object msg)
Called when a new message was read and decoded from the input buffer.
|
void |
read(SocketAddress remoteAddress,
byte[] datagram)
Called when a new datagram was received from a remote end that is identified
by the given remote address.
|
void |
read(SocketAddress remoteAddress,
Object msg)
Called when a new message was received and decoded from a remote end
that is identified by the given remote address.
|
void |
timer(Runnable task)
Called to notify about an expiration of the timer associated with the
specified task.
|
event, getSession, read, setSession
event, exception, getName, incident, read, timer
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
event, exception, getName, incident, read, timer
read
public HeartbeatHandler(ITimer timer, long beatPeriod, long downPeriod)
public HeartbeatHandler(SocketAddress remoteAddress, ITimer timer, long beatPeriod, long downPeriod)
public void read(byte[] data)
AbstractHandler
read
methods are
met.
The passed array can be safely stored or modified by this method as it will not be used by the caller.
By default it simply passes the data
value to the
IHandler.read(Object)
method.
read
in interface IHandler
read
in interface IDatagramReader
read
in class AbstractHandler
data
- bytes that was read from the input buffer.public void read(SocketAddress remoteAddress, byte[] datagram)
AbstractDatagramHandler
This method is called when none of the conditions for calling other
read
methods with specified remote address are met.
The passed array can be safely stored or modified by this method as it will not be used by the caller.
By default it simply passes the remoteAddress
and data
values
to the IDatagramHandler.read(SocketAddress,Object)
method.
read
in interface IDatagramHandler
read
in interface IDatagramReader
read
in class AbstractDatagramHandler
remoteAddress
- address of the remote end.datagram
- the datagram received from the remote end.public void read(Object msg)
IHandler
byte[]
and ByteBuffer
.msg
- the message that was read and decoded from the input buffer.public void read(SocketAddress remoteAddress, Object msg)
IDatagramHandler
byte[]
and ByteBuffer
.
The method is only called for sessions created with a disconnected datagram channel.
remoteAddress
- address of the remote end.msg
- the message received from the remote end.public void event(SessionEvent event)
IHandler
event
in interface IHandler
event
in class AbstractHandler
event
- an event related with the change of the session stateSessionEvent
public void timer(Runnable task)
IHandler
timer
in interface IHandler
timer
in class AbstractHandler
task
- the task to executepublic ISessionConfig getConfig()
IHandler
getConfig
in interface IHandler
getConfig
in class AbstractHandler
ISessionConfig
public ISessionStructureFactory getFactory()
IHandler
getFactory
in interface IHandler
getFactory
in class AbstractHandler
ISessionStructureFactory
Copyright © 2017–2022 SNF4J.ORG. All rights reserved.