Schnittstelle Router
- Alle bekannten Implementierungsklassen:
RouterImpl
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:
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidbroadcast(byte[] bytes) Call this method to broadcast a UDP message to all hosts on the network.booleandisable()Unbinds all sockets and stops all listening threads for datagrams and streams.booleanenable()Starts all sockets and listening threads for datagrams and streams.getActiveStreamServers(InetAddress preferredAddress) voidCalled by theenable()method before it returns.booleanvoidThis method is called internally by the transport layer when a datagram, either unicast or multicast, has been received.voidreceived(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.voidCall this method to send a UDP datagram message.send(StreamRequestMessage msg) Call this method to send a TCP (HTTP) stream message.voidshutdown()Disables the router and releases all other resources.
-
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
Starts all sockets and listening threads for datagrams and streams.- Gibt zurück:
trueif the router was enabled.falseif it's already running.- Löst aus:
RouterException
-
disable
Unbinds all sockets and stops all listening threads for datagrams and streams.- Gibt zurück:
trueif the router was disabled.falseif it wasn't running.- Löst aus:
RouterException
-
shutdown
Disables the router and releases all other resources.- Löst aus:
RouterException
-
isEnabled
- Gibt zurück:
trueif the router is currently enabled.- Löst aus:
RouterException
-
handleStartFailure
Called by theenable()method before it returns.- Parameter:
e- The cause of the failure.- Löst aus:
InitializationException- if the exception was not recoverable.
-
getActiveStreamServers
- Parameter:
preferredAddress- A preferred stream server bound address ornull.- 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
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
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
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.
-