| 
    YAACC - UPNP Client and Server
    
   | 
 
Default implementation of network message router. More...


Public Member Functions | |
| RouterImpl (UpnpServiceConfiguration configuration, ProtocolFactory protocolFactory) | |
| boolean | enable (@Observes @Default EnableRouter event) throws RouterException | 
| boolean | disable (@Observes @Default DisableRouter event) throws RouterException | 
| UpnpServiceConfiguration | getConfiguration () | 
| ProtocolFactory | getProtocolFactory () | 
| boolean | enable () throws RouterException | 
Initializes listening services: First an instance of org.fourthline.cling.transport.spi.MulticastReceiver is bound to each network interface.   | |
| boolean | disable () throws RouterException | 
| Unbinds all sockets and stops all listening threads for datagrams and streams.   | |
| void | shutdown () throws RouterException | 
| Disables the router and releases all other resources.   | |
| boolean | isEnabled () | 
| void | handleStartFailure (InitializationException ex) throws InitializationException | 
Called by the enable() method before it returns.   | |
| List< NetworkAddress > | getActiveStreamServers (InetAddress preferredAddress) throws RouterException | 
| void | received (IncomingDatagramMessage msg) | 
Obtains the asynchronous protocol Executor and runs the protocol created by the org.fourthline.cling.protocol.ProtocolFactory for the given message.   | |
| void | received (UpnpStream stream) | 
Obtains the synchronous protocol Executor and runs the org.fourthline.cling.transport.spi.UpnpStream directly.   | |
| void | send (OutgoingDatagramMessage msg) throws RouterException | 
Sends the UDP datagram on all bound org.fourthline.cling.transport.spi.DatagramIOs.   | |
| StreamResponseMessage | send (StreamRequestMessage msg) throws RouterException | 
Sends the TCP stream request with the org.fourthline.cling.transport.spi.StreamClient.   | |
| void | broadcast (byte[] bytes) throws RouterException | 
Sends the given bytes as a broadcast on all bound org.fourthline.cling.transport.spi.DatagramIOs, using source port 9.   | |
Protected Member Functions | |
| void | startInterfaceBasedTransports (Iterator< NetworkInterface > interfaces) throws InitializationException | 
| void | startAddressBasedTransports (Iterator< InetAddress > addresses) throws InitializationException | 
| void | lock (Lock lock, int timeoutMilliseconds) throws RouterException | 
| void | lock (Lock lock) throws RouterException | 
| void | unlock (Lock lock) | 
| int | getLockTimeoutMillis () | 
Protected Attributes | |
| final Map< NetworkInterface, MulticastReceiver > | multicastReceivers = new HashMap<>() | 
| final Map< InetAddress, DatagramIO > | datagramIOs = new HashMap<>() | 
| final Map< InetAddress, StreamServer > | streamServers = new HashMap<>() | 
| UpnpServiceConfiguration | configuration | 
| ProtocolFactory | protocolFactory | 
| volatile boolean | enabled | 
| ReentrantReadWriteLock | routerLock = new ReentrantReadWriteLock(true) | 
| Lock | readLock = routerLock.readLock() | 
| Lock | writeLock = routerLock.writeLock() | 
| NetworkAddressFactory | networkAddressFactory | 
| StreamClient | streamClient | 
Default implementation of network message router.
Initializes and starts listening for data on the network when enabled.
| org.fourthline.cling.transport.RouterImpl.RouterImpl | ( | UpnpServiceConfiguration | configuration, | 
| ProtocolFactory | protocolFactory | ||
| ) | 
| configuration | The configuration used by this router. | 
| protocolFactory | The protocol factory used by this router. | 
| void org.fourthline.cling.transport.RouterImpl.broadcast | ( | byte[] | bytes | ) | throws RouterException | 
Sends the given bytes as a broadcast on all bound org.fourthline.cling.transport.spi.DatagramIOs, using source port 9. 
TODO: Support source port parameter
| bytes | The byte payload of the UDP datagram. | 
Implements org.fourthline.cling.transport.Router.
Referenced by org.fourthline.cling.transport.RouterImpl.broadcast().


| boolean org.fourthline.cling.transport.RouterImpl.disable | ( | ) | throws RouterException | 
Unbinds all sockets and stops all listening threads for datagrams and streams.
true if the router was disabled. false if it wasn't running. Implements org.fourthline.cling.transport.Router.
Referenced by org.fourthline.cling.transport.RouterImpl.shutdown().

| boolean org.fourthline.cling.transport.RouterImpl.enable | ( | ) | throws RouterException | 
Initializes listening services: First an instance of org.fourthline.cling.transport.spi.MulticastReceiver is bound to each network interface. 
Then an instance of org.fourthline.cling.transport.spi.DatagramIO and org.fourthline.cling.transport.spi.StreamServer is bound to each bind address returned by the network address factory, respectively. There is only one instance of org.fourthline.cling.transport.spi.StreamClient created and managed by this router. 
Implements org.fourthline.cling.transport.Router.

| List< NetworkAddress > org.fourthline.cling.transport.RouterImpl.getActiveStreamServers | ( | InetAddress | preferredAddress | ) | throws RouterException | 
| preferredAddress | A preferred stream server bound address or null.  | 
Implements org.fourthline.cling.transport.Router.
| UpnpServiceConfiguration org.fourthline.cling.transport.RouterImpl.getConfiguration | ( | ) | 
Implements org.fourthline.cling.transport.Router.
Referenced by org.fourthline.cling.transport.RouterImpl.enable(), org.fourthline.cling.transport.RouterImpl.received(), and org.fourthline.cling.transport.RouterImpl.received().

      
  | 
  protected | 
| ProtocolFactory org.fourthline.cling.transport.RouterImpl.getProtocolFactory | ( | ) | 
Implements org.fourthline.cling.transport.Router.
Referenced by org.fourthline.cling.transport.RouterImpl.received().

| void org.fourthline.cling.transport.RouterImpl.handleStartFailure | ( | InitializationException | ex | ) | throws InitializationException | 
Called by the enable() method before it returns. 
| ex | The cause of the failure. | 
| InitializationException | if the exception was not recoverable. | 
Implements org.fourthline.cling.transport.Router.
Referenced by org.fourthline.cling.transport.RouterImpl.enable().

| boolean org.fourthline.cling.transport.RouterImpl.isEnabled | ( | ) | 
true if the router is currently enabled. Implements org.fourthline.cling.transport.Router.
| void org.fourthline.cling.transport.RouterImpl.received | ( | IncomingDatagramMessage | msg | ) | 
Obtains the asynchronous protocol Executor and runs the protocol created by the org.fourthline.cling.protocol.ProtocolFactory for the given message. 
If the factory doesn't create a protocol, the message is dropped immediately without creating another thread or consuming further resources. This means we can filter the datagrams in the protocol factory and e.g. completely disable discovery or only allow notification message from some known services we'd like to work with.
| msg | The received datagram message. | 
Implements org.fourthline.cling.transport.Router.

| void org.fourthline.cling.transport.RouterImpl.received | ( | UpnpStream | stream | ) | 
Obtains the synchronous protocol Executor and runs the org.fourthline.cling.transport.spi.UpnpStream directly. 
| stream | The received org.fourthline.cling.transport.spi.UpnpStream.  | 
Implements org.fourthline.cling.transport.Router.

| void org.fourthline.cling.transport.RouterImpl.send | ( | OutgoingDatagramMessage | msg | ) | throws RouterException | 
Sends the UDP datagram on all bound org.fourthline.cling.transport.spi.DatagramIOs. 
| msg | The UDP datagram message to send. | 
Implements org.fourthline.cling.transport.Router.
| StreamResponseMessage org.fourthline.cling.transport.RouterImpl.send | ( | StreamRequestMessage | msg | ) | throws RouterException | 
Sends the TCP stream request with the org.fourthline.cling.transport.spi.StreamClient. 
| msg | The TCP (HTTP) stream message to send. | 
org.fourthline.cling.transport.spi.StreamClient#sendRequest(StreamRequestMessage) method or null if no StreamClient is available. Implements org.fourthline.cling.transport.Router.
| void org.fourthline.cling.transport.RouterImpl.shutdown | ( | ) | throws RouterException | 
Disables the router and releases all other resources.
Implements org.fourthline.cling.transport.Router.
