YAACC - UPNP Client and Server
|
Interface of the network transport layer. More...
Public Member Functions | |
UpnpServiceConfiguration | getConfiguration () |
ProtocolFactory | getProtocolFactory () |
boolean | enable () throws RouterException |
Starts all sockets and listening threads for datagrams and streams. | |
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 () throws RouterException |
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) |
void | received (UpnpStream stream) |
void | send (OutgoingDatagramMessage msg) throws RouterException |
StreamResponseMessage | send (StreamRequestMessage msg) throws RouterException |
void | broadcast (byte[] bytes) throws RouterException |
Interface of the network transport layer.
Encapsulates the transport layer and provides methods to the upper layers for sending UPnP stream (HTTP) org.fourthline.cling.model.message.StreamRequestMessage
s, sending (UDP) datagram org.fourthline.cling.model.message.OutgoingDatagramMessage
s, as well as broadcasting bytes to all LAN participants.
A router also maintains listening sockets and services, for incoming UDP unicast/multicast org.fourthline.cling.model.message.IncomingDatagramMessage
and TCP org.fourthline.cling.transport.spi.UpnpStream
s. 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.
void org.fourthline.cling.transport.Router.broadcast | ( | byte[] | bytes | ) | throws RouterException |
Call this method to broadcast a UDP message to all hosts on the network.
bytes | The byte payload of the UDP datagram. |
RouterException | if a recoverable error, such as thread interruption, occurs. |
Implemented in org.fourthline.cling.transport.RouterImpl.
boolean org.fourthline.cling.transport.Router.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. Implemented in org.fourthline.cling.transport.RouterImpl.
boolean org.fourthline.cling.transport.Router.enable | ( | ) | throws RouterException |
Starts all sockets and listening threads for datagrams and streams.
true
if the router was enabled. false
if it's already running. Implemented in org.fourthline.cling.transport.RouterImpl.
List< NetworkAddress > org.fourthline.cling.transport.Router.getActiveStreamServers | ( | InetAddress | preferredAddress | ) | throws RouterException |
preferredAddress | A preferred stream server bound address or null . |
Implemented in org.fourthline.cling.transport.RouterImpl.
UpnpServiceConfiguration org.fourthline.cling.transport.Router.getConfiguration | ( | ) |
Implemented in org.fourthline.cling.transport.RouterImpl.
ProtocolFactory org.fourthline.cling.transport.Router.getProtocolFactory | ( | ) |
Implemented in org.fourthline.cling.transport.RouterImpl.
void org.fourthline.cling.transport.Router.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. |
Implemented in org.fourthline.cling.transport.RouterImpl.
boolean org.fourthline.cling.transport.Router.isEnabled | ( | ) | throws RouterException |
true
if the router is currently enabled. Implemented in org.fourthline.cling.transport.RouterImpl.
void org.fourthline.cling.transport.Router.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.
msg | The received datagram message. |
Implemented in org.fourthline.cling.transport.RouterImpl.
void org.fourthline.cling.transport.Router.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.
stream |
Implemented in org.fourthline.cling.transport.RouterImpl.
void org.fourthline.cling.transport.Router.send | ( | OutgoingDatagramMessage | msg | ) | throws RouterException |
Call this method to send a UDP datagram message.
msg | The UDP datagram message to send. |
RouterException | if a recoverable error, such as thread interruption, occurs. |
Implemented in org.fourthline.cling.transport.RouterImpl.
StreamResponseMessage org.fourthline.cling.transport.Router.send | ( | StreamRequestMessage | msg | ) | throws RouterException |
Call this method to send a TCP (HTTP) stream message.
msg | The TCP (HTTP) stream message to send. |
RouterException | if a recoverable error, such as thread interruption, occurs. |
Implemented in org.fourthline.cling.transport.RouterImpl.
void org.fourthline.cling.transport.Router.shutdown | ( | ) | throws RouterException |
Disables the router and releases all other resources.
Implemented in org.fourthline.cling.transport.RouterImpl.