Schnittstelle Router

Alle bekannten Implementierungsklassen:
RouterImpl

public interface Router
Interface of the network transport layer.

Encapsulates the transport layer and provides methods to the upper layers for sending UPnP stream (HTTP) StreamRequestMessages, sending (UDP) datagram OutgoingDatagramMessages, as well as broadcasting bytes to all LAN participants.

A router also maintains listening sockets and services, for incoming UDP unicast/multicast IncomingDatagramMessage and TCP UpnpStreams. An implementation of this interface handles these messages, e.g. by selecting and executing the right protocol.

An implementation must be thread-safe, and can be accessed concurrently. If the Router is disabled, it doesn't listen on the network for incoming messages and does not send outgoing messages.

Autor:
Christian Bauer
Siehe auch:
  • Methodendetails

    • getConfiguration

      UpnpServiceConfiguration getConfiguration()
      Gibt zurück:
      The configuration used by this router.
    • getProtocolFactory

      ProtocolFactory getProtocolFactory()
      Gibt zurück:
      The protocol factory used by this router.
    • enable

      boolean enable() throws RouterException
      Starts all sockets and listening threads for datagrams and streams.
      Gibt zurück:
      true if the router was enabled. false if it's already running.
      Löst aus:
      RouterException
    • disable

      boolean disable() throws RouterException
      Unbinds all sockets and stops all listening threads for datagrams and streams.
      Gibt zurück:
      true if the router was disabled. false if it wasn't running.
      Löst aus:
      RouterException
    • shutdown

      void shutdown() throws RouterException
      Disables the router and releases all other resources.
      Löst aus:
      RouterException
    • isEnabled

      boolean isEnabled() throws RouterException
      Gibt zurück:
      true if the router is currently enabled.
      Löst aus:
      RouterException
    • handleStartFailure

      void handleStartFailure(InitializationException e) throws InitializationException
      Called by the enable() method before it returns.
      Parameter:
      e - The cause of the failure.
      Löst aus:
      InitializationException - if the exception was not recoverable.
    • getActiveStreamServers

      List<NetworkAddress> getActiveStreamServers(InetAddress preferredAddress) throws RouterException
      Parameter:
      preferredAddress - A preferred stream server bound address or null.
      Gibt zurück:
      An empty list if no stream server is currently active, otherwise a single network address if the preferred address is active, or a list of all active bound stream servers.
      Löst aus:
      RouterException
    • received

      void received(IncomingDatagramMessage msg)

      This method is called internally by the transport layer when a datagram, either unicast or multicast, has been received. An implementation of this interface has to handle the received message, e.g. selecting and executing a UPnP protocol. This method should not block until the execution completes, the calling thread should be free to handle the next reception as soon as possible.

      Parameter:
      msg - The received datagram message.
    • received

      void received(UpnpStream stream)

      This method is called internally by the transport layer when a TCP stream connection has been made and a response has to be returned to the sender. An implementation of this interface has to handle the received stream connection and return a response, e.g. selecting and executing a UPnP protocol. This method should not block until the execution completes, the calling thread should be free to process the next reception as soon as possible. Typically this means starting a new thread of execution in this method.

      Parameter:
      stream -
    • send

      Call this method to send a UDP datagram message.

      Parameter:
      msg - The UDP datagram message to send.
      Löst aus:
      RouterException - if a recoverable error, such as thread interruption, occurs.
    • send

      Call this method to send a TCP (HTTP) stream message.

      Parameter:
      msg - The TCP (HTTP) stream message to send.
      Gibt zurück:
      The response received from the server.
      Löst aus:
      RouterException - if a recoverable error, such as thread interruption, occurs.
    • broadcast

      void broadcast(byte[] bytes) throws RouterException

      Call this method to broadcast a UDP message to all hosts on the network.

      Parameter:
      bytes - The byte payload of the UDP datagram.
      Löst aus:
      RouterException - if a recoverable error, such as thread interruption, occurs.