|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fourthline.cling.transport.impl.DatagramIOImpl
public class DatagramIOImpl
Default implementation based on a single shared (receive/send) UDP MulticastSocket
.
Although we do not receive multicast datagrams with this service, sending multicast
datagrams with a configuration time-to-live requires a MulticastSocket
.
Thread-safety is guaranteed through synchronization of methods of this service and by the thread-safe underlying socket.
Field Summary | |
---|---|
protected DatagramIOConfigurationImpl |
configuration
|
protected DatagramProcessor |
datagramProcessor
|
protected InetSocketAddress |
localAddress
|
protected Router |
router
|
protected MulticastSocket |
socket
|
Constructor Summary | |
---|---|
DatagramIOImpl(DatagramIOConfigurationImpl configuration)
|
Method Summary | |
---|---|
DatagramIOConfigurationImpl |
getConfiguration()
|
void |
init(InetAddress bindAddress,
Router router,
DatagramProcessor datagramProcessor)
Configures the service and starts any listening sockets. |
void |
run()
|
void |
send(DatagramPacket datagram)
The actual sending of a UDP datagram. |
void |
send(OutgoingDatagramMessage message)
Sends a datagram after conversion with DatagramProcessor.write(org.fourthline.cling.model.message.OutgoingDatagramMessage) . |
void |
stop()
Stops the service, closes any listening sockets. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final DatagramIOConfigurationImpl configuration
protected Router router
protected DatagramProcessor datagramProcessor
protected InetSocketAddress localAddress
protected MulticastSocket socket
Constructor Detail |
---|
public DatagramIOImpl(DatagramIOConfigurationImpl configuration)
Method Detail |
---|
public DatagramIOConfigurationImpl getConfiguration()
getConfiguration
in interface DatagramIO<DatagramIOConfigurationImpl>
public void init(InetAddress bindAddress, Router router, DatagramProcessor datagramProcessor) throws InitializationException
DatagramIO
init
in interface DatagramIO<DatagramIOConfigurationImpl>
bindAddress
- The address to bind any sockets on.router
- The router which handles received IncomingDatagramMessage
s.datagramProcessor
- Reads and writes datagrams.
InitializationException
- If the service could not be initialized or started.public void stop()
DatagramIO
stop
in interface DatagramIO<DatagramIOConfigurationImpl>
public void run()
run
in interface Runnable
public void send(OutgoingDatagramMessage message)
DatagramIO
DatagramProcessor.write(org.fourthline.cling.model.message.OutgoingDatagramMessage)
.
send
in interface DatagramIO<DatagramIOConfigurationImpl>
message
- The message to send.public void send(DatagramPacket datagram)
DatagramIO
Recoverable errors should be logged, if appropriate only with debug level. Any
non-recoverable errors should be thrown as RuntimeException
s.
send
in interface DatagramIO<DatagramIOConfigurationImpl>
datagram
- The UDP datagram to send.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |