public abstract class AbstractDatagramHandler extends AbstractHandler implements IDatagramHandler
IDatagramHandler
interface.Modifier | Constructor and Description |
---|---|
protected |
AbstractDatagramHandler()
Default constructor creating an unnamed datagram-oriented handler.
|
protected |
AbstractDatagramHandler(String name)
Constructor creating a named datagram-oriented handler.
|
Modifier and Type | Method and Description |
---|---|
void |
event(SocketAddress remoteAddress,
DataEvent event,
long length)
Called to notify about an I/O operation related to a specified remote host.
|
IDatagramSession |
getSession()
Returns the session that is associated with this handler.
|
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,
ByteBuffer datagram)
Called when a new datagram was received from a remote end that is identified
by the given remote address.
|
void |
setSession(ISession session)
Sets the datagram-oriented session that will be associated with this
handler.
|
event, event, exception, getConfig, getFactory, getName, incident, read, read, timer, timer
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
read
event, event, exception, getConfig, getFactory, getName, incident, read, read, read, timer, timer
read, read
protected AbstractDatagramHandler()
protected AbstractDatagramHandler(String name)
name
- the name for this handlerpublic void setSession(ISession session)
setSession
in interface IDatagramHandler
setSession
in interface IHandler
setSession
in class AbstractHandler
session
- the sessionIllegalArgumentException
- if the session argument is not an instance of the
IDatagramSession
interface.public IDatagramSession getSession()
IHandler
getSession
in interface IDatagramHandler
getSession
in interface IHandler
getSession
in class AbstractHandler
public void read(SocketAddress remoteAddress, byte[] datagram)
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
remoteAddress
- address of the remote end.datagram
- the datagram received from the remote end.public void read(SocketAddress remoteAddress, ByteBuffer datagram)
This method is called when the associated session is configured with a codec
pipeline in which the last decoder produces ByteBuffer
objects or
when the associated session is configured to optimize data copying and uses
an allocator supporting the releasing of no longer used buffers.
The passed buffer can be safely stored or modified by this method as it will not be used by the caller. However, if the associated session is configured to optimize data copying and uses an allocator supporting the releasing of no longer used buffers it may be required to release it in this method unless the original buffer has been already released by one of the associated decoders.
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
remoteAddress
- address of the remote end.datagram
- the datagram received from the remote end.public void event(SocketAddress remoteAddress, DataEvent event, long length)
IDatagramHandler
event
in interface IDatagramHandler
remoteAddress
- the address of the remote hostevent
- an event related with the type of I/O operationlength
- the number of bytes related with the I/O operationDataEvent
Copyright © 2017–2021 SNF4J.ORG. All rights reserved.