public class UDPSocketHelper.UDPSocket
extends java.lang.Object
Constructor and Description |
---|
UDPSocket(jdk.nashorn.api.scripting.ScriptObjectMirror currentObj,
boolean enableBroadcast)
Construct a socket.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_emitMessage(io.vertx.core.buffer.Buffer buffer,
java.lang.String sender)
Convert the buffer to a message depending on the specified receive type
and emit a 'message' event.
|
void |
bind(int port,
java.lang.String address,
jdk.nashorn.api.scripting.ScriptObjectMirror callback)
Listen for datagram messages on the specified port and optional address.
|
void |
close()
Close the UDP socket.
|
void |
send(java.lang.Object data,
int port,
java.lang.String hostname,
jdk.nashorn.api.scripting.ScriptObjectMirror callback)
Send a datagram message.
|
void |
setRawBytes(boolean rawBytes)
Set raw bytes support.
|
void |
setReceiveType(java.lang.String type)
Set the receive type.
|
void |
setSendType(java.lang.String type)
Set the send type.
|
public UDPSocket(jdk.nashorn.api.scripting.ScriptObjectMirror currentObj, boolean enableBroadcast)
currentObj
- The corresponding JavaScript Socket object.enableBroadcast
- enabling or not message broadcastingpublic void bind(int port, java.lang.String address, jdk.nashorn.api.scripting.ScriptObjectMirror callback)
port
- The port number.address
- The address of the network interface on which to listen,
or "0.0.0.0" to listen on all addresses.callback
- A callback function to invoke when the binding is complete,
or null to not request a callback.public void close()
public void send(java.lang.Object data, int port, java.lang.String hostname, jdk.nashorn.api.scripting.ScriptObjectMirror callback)
data
- The data to send.port
- The destination port.hostname
- The name of the destination host (a hostname or IP address).callback
- An optional callback function to invoke when the send is complete,
or if an error occurs. In the latter case, the cause of the error will be passed
as an argument to the callback.public void setRawBytes(boolean rawBytes)
rawBytes
- The value of rawBytes.public void setReceiveType(java.lang.String type)
type
- The name of the receive type.public void setSendType(java.lang.String type)
type
- The name of the send type.protected void _emitMessage(io.vertx.core.buffer.Buffer buffer, java.lang.String sender)
buffer
- The buffer containing the message.sender
- A string containing the IP address and port of the sender.