public interface IDatagramHandler extends IHandler, IDatagramReader
IHandler
interface to cover datagram-oriented functionalities.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 datagram-oriented 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 |
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 |
setSession(ISession session)
Sets the datagram-oriented session that will be associated with this handler.
|
event, event, exception, getConfig, getFactory, getName, incident, read, read, read, timer, timer
read, read
void setSession(ISession session)
setSession
in interface IHandler
session
- the datagram-oriented sessionIllegalArgumentException
- when the session argument is not an instance of the
IDatagramSession
interface.IDatagramSession getSession()
getSession
in interface IHandler
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.
read
in interface IDatagramReader
remoteAddress
- address of the remote end.datagram
- the datagram received from the remote end.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.
read
in interface IDatagramReader
remoteAddress
- address of the remote end.datagram
- the datagram received from the remote end.void read(SocketAddress remoteAddress, Object msg)
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.void event(SocketAddress remoteAddress, DataEvent event, long length)
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–2022 SNF4J.ORG. All rights reserved.