|
||||||||||
| 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 DatagramIOs,
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 DatagramIOs. |
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 Routerpublic ProtocolFactory getProtocolFactory()
getProtocolFactory in interface Routerpublic NetworkAddressFactory getNetworkAddressFactory()
getNetworkAddressFactory in interface Routerprotected 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 Routeraddress - 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 Routerpublic void received(IncomingDatagramMessage msg)
Executor and runs the protocol created
by the ProtocolFactory for the given message.
received in interface Routermsg - The received datagram message.public void received(UpnpStream stream)
Executor and runs the
UpnpStream directly.
received in interface Routerstream - The received UpnpStream.public void send(OutgoingDatagramMessage msg)
DatagramIOs.
send in interface Routermsg - The UDP datagram message to send.public StreamResponseMessage send(StreamRequestMessage msg)
StreamClient.
send in interface Routermsg - The TCP (HTTP) stream message to send.
StreamClient.sendRequest(StreamRequestMessage)
method or null if no StreamClient is available.public void broadcast(byte[] bytes)
DatagramIOs,
using source port 9.
TODO: Support source port parameter
broadcast in interface Routerbytes - The byte payload of the UDP datagram.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||