|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object akka.io.UdpMessage
public class UdpMessage
Java API: factory methods for the message types used when communicating with the Udp service.
Constructor Summary | |
---|---|
UdpMessage()
|
Method Summary | |
---|---|
static Udp.Command |
bind(ActorRef handler,
java.net.InetSocketAddress endpoint)
Bind without specifying options. |
static Udp.Command |
bind(ActorRef handler,
java.net.InetSocketAddress endpoint,
java.lang.Iterable<Inet.SocketOption> options)
Send this message to the UdpExt.manager() in order to bind to the given
local port (or an automatically assigned one if the port number is zero). |
static Udp.NoAck |
noAck()
Default NoAck instance which is used when no acknowledgment information is
explicitly provided. |
static Udp.NoAck |
noAck(java.lang.Object token)
Each Send can optionally request a positive acknowledgment to be sent
to the commanding actor. |
static Udp.Command |
resumeReading()
This message must be sent to the listener actor to re-enable reading from the socket after a SuspendReading command. |
static Udp.Command |
send(ByteString payload,
java.net.InetSocketAddress target)
The same as send(payload, target, noAck()) . |
static Udp.Command |
send(ByteString payload,
java.net.InetSocketAddress target,
Udp.Event ack)
This message is understood by the “simple sender” which can be obtained by sending the SimpleSender query to the UdpExt.manager() as well as by
the listener actors which are created in response to Bind . |
static Udp.Command |
simpleSender()
Retrieve a simple sender without specifying options. |
static Udp.Command |
simpleSender(java.lang.Iterable<Inet.SocketOption> options)
Retrieve a reference to a “simple sender” actor of the UDP extension. |
static Udp.Command |
suspendReading()
Send this message to a listener actor (which sent a Bound message) to
have it stop reading datagrams from the network. |
static Udp.Command |
unbind()
Send this message to the listener actor that previously sent a Bound
message in order to close the listening socket. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UdpMessage()
Method Detail |
---|
public static Udp.NoAck noAck(java.lang.Object token)
Send
can optionally request a positive acknowledgment to be sent
to the commanding actor. If such notification is not desired the Send#ack
must be set to an instance of this class. The token contained within can be used
to recognize which write failed when receiving a CommandFailed
message.
public static Udp.NoAck noAck()
NoAck
instance which is used when no acknowledgment information is
explicitly provided. Its “token” is null
.
public static Udp.Command send(ByteString payload, java.net.InetSocketAddress target, Udp.Event ack)
SimpleSender
query to the UdpExt.manager()
as well as by
the listener actors which are created in response to Bind
. It will send
the given payload data as one UDP datagram to the given target address. The
UDP actor will respond with CommandFailed
if the send could not be
enqueued to the O/S kernel because the send buffer was full. If the given
ack
is not of type NoAck
the UDP actor will reply with the given
object as soon as the datagram has been successfully enqueued to the O/S
kernel.
The sending UDP socket’s address belongs to the “simple sender” which does
not handle inbound datagrams and sends from an ephemeral port; therefore
sending using this mechanism is not suitable if replies are expected, use
Bind
in that case.
public static Udp.Command send(ByteString payload, java.net.InetSocketAddress target)
send(payload, target, noAck())
.
public static Udp.Command bind(ActorRef handler, java.net.InetSocketAddress endpoint, java.lang.Iterable<Inet.SocketOption> options)
UdpExt.manager()
in order to bind to the given
local port (or an automatically assigned one if the port number is zero).
The listener actor for the newly bound port will reply with a Bound
message, or the manager will reply with a CommandFailed
message.
public static Udp.Command bind(ActorRef handler, java.net.InetSocketAddress endpoint)
public static Udp.Command unbind()
Bound
message in order to close the listening socket. The recipient will reply
with an Unbound
message.
public static Udp.Command simpleSender(java.lang.Iterable<Inet.SocketOption> options)
SimpleSenderReady
notification.
The “simple sender” is a convenient service for being able to send datagrams when the originating address is meaningless, i.e. when no reply is expected.
The “simple sender” will not stop itself, you will have to send it a PoisonPill
when you want to close the socket.
public static Udp.Command simpleSender()
public static Udp.Command suspendReading()
Bound
message) to
have it stop reading datagrams from the network. If the O/S kernel’s receive
buffer runs full then subsequent datagrams will be silently discarded.
Re-enable reading from the socket using the ResumeReading
command.
public static Udp.Command resumeReading()
SuspendReading
command.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |