|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.teleal.cling.transport.RouterImpl
public class RouterImpl
Default implementation of network message router.
Initializes and starts listenting for data on the network immediately on construction.
Field Summary | |
---|---|
protected UpnpServiceConfiguration |
configuration
|
protected Map<InetAddress,DatagramIO> |
datagramIOs
|
protected Map<NetworkInterface,MulticastReceiver> |
multicastReceivers
|
protected NetworkAddressFactory |
networkAddressFactory
|
protected ProtocolFactory |
protocolFactory
|
protected StreamClient |
streamClient
|
protected Map<InetAddress,StreamServer> |
streamServers
|
Constructor Summary | |
---|---|
RouterImpl(UpnpServiceConfiguration configuration,
ProtocolFactory protocolFactory)
Creates a NetworkAddressFactory from the given
UpnpServiceConfiguration and initializes listening services. |
Method Summary | |
---|---|
void |
broadcast(byte[] bytes)
Sends the given bytes as a broadcast on all bound DatagramIO s,
using source port 9. |
UpnpServiceConfiguration |
getConfiguration()
|
protected Map<InetAddress,DatagramIO> |
getDatagramIOs()
|
int |
getLocalStreamPort(InetAddress address)
|
protected Map<NetworkInterface,MulticastReceiver> |
getMulticastReceivers()
|
NetworkAddressFactory |
getNetworkAddressFactory()
|
ProtocolFactory |
getProtocolFactory()
|
protected StreamClient |
getStreamClient()
|
protected Map<InetAddress,StreamServer> |
getStreamServers()
|
void |
received(IncomingDatagramMessage msg)
Obtains the asynchronous protocol Executor and runs the protocol created
by the ProtocolFactory for the given message. |
void |
received(UpnpStream stream)
Obtains the synchronous protocol Executor and runs the
UpnpStream directly. |
void |
send(OutgoingDatagramMessage msg)
Sends the UDP datagram on all bound DatagramIO s. |
StreamResponseMessage |
send(StreamRequestMessage msg)
Sends the TCP stream request with the StreamClient . |
void |
shutdown()
Unbinds all sockets and stops all listening threads for datagrams and streams. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final UpnpServiceConfiguration configuration
protected final ProtocolFactory protocolFactory
protected final StreamClient streamClient
protected final NetworkAddressFactory networkAddressFactory
protected final Map<NetworkInterface,MulticastReceiver> multicastReceivers
protected final Map<InetAddress,DatagramIO> datagramIOs
protected final Map<InetAddress,StreamServer> streamServers
Constructor Detail |
---|
public RouterImpl(UpnpServiceConfiguration configuration, ProtocolFactory protocolFactory) throws InitializationException
NetworkAddressFactory
from the given
UpnpServiceConfiguration
and initializes listening services. First an instance
of MulticastReceiver
is bound to eatch network interface. Then
an instance of DatagramIO
and StreamServer
is bound to each bind address
returned by the network address factory, respectively. There is only one instance of
StreamClient
created and managed by this router.
configuration
- The configuration used by this router.protocolFactory
- The protocol factory used by this router.
InitializationException
- When initialization of any listening network service fails.Method Detail |
---|
public UpnpServiceConfiguration getConfiguration()
getConfiguration
in interface Router
public ProtocolFactory getProtocolFactory()
getProtocolFactory
in interface Router
public NetworkAddressFactory getNetworkAddressFactory()
getNetworkAddressFactory
in interface Router
protected Map<NetworkInterface,MulticastReceiver> getMulticastReceivers()
protected Map<InetAddress,DatagramIO> getDatagramIOs()
protected StreamClient getStreamClient()
protected Map<InetAddress,StreamServer> getStreamServers()
public int getLocalStreamPort(InetAddress address)
getLocalStreamPort
in interface Router
address
- A bound address of a local network interface.
0
if
the given address was not managed by this router.public void shutdown()
Router
shutdown
in interface Router
public void received(IncomingDatagramMessage msg)
Executor
and runs the protocol created
by the ProtocolFactory
for the given message.
received
in interface Router
msg
- The received datagram message.public void received(UpnpStream stream)
Executor
and runs the
UpnpStream
directly.
received
in interface Router
stream
- The received UpnpStream
.public void send(OutgoingDatagramMessage msg)
DatagramIO
s.
send
in interface Router
msg
- The UDP datagram message to send.public StreamResponseMessage send(StreamRequestMessage msg)
StreamClient
.
send
in interface Router
msg
- The TCP (HTTP) stream message to send.
StreamClient.sendRequest(StreamRequestMessage)
method or null
if no StreamClient
is available.public void broadcast(byte[] bytes)
DatagramIO
s,
using source port 9.
TODO: Support source port parameter
broadcast
in interface Router
bytes
- The byte payload of the UDP datagram.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |