|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teleal.cling.transport.SwitchableRouterImpl
public class SwitchableRouterImpl
Default implementation of switchable network message router.
This implementation is actually wrapping a regular
RouterImpl, making it on/off
switchable.
If the router can't be enabled (e.g. an exception occurs during
socket binding), a warning log message will be printed. You can customize this behavior by
overriding handleStartFailure(org.teleal.cling.transport.spi.InitializationException).
| Constructor Summary | |
|---|---|
SwitchableRouterImpl(UpnpServiceConfiguration configuration,
ProtocolFactory protocolFactory)
|
|
| Method Summary | |
|---|---|
void |
broadcast(byte[] bytes)
Call this method to broadcast a UDP message to all hosts on the network. |
boolean |
disable()
|
boolean |
enable()
|
List<NetworkAddress> |
getActiveStreamServers(InetAddress preferredAddress)
|
UpnpServiceConfiguration |
getConfiguration()
|
NetworkAddressFactory |
getNetworkAddressFactory()
|
ProtocolFactory |
getProtocolFactory()
|
void |
handleStartFailure(InitializationException ex)
Called by the SwitchableRouter.enable() method before it returns. |
boolean |
isEnabled()
|
void |
received(IncomingDatagramMessage msg)
This method is called internally by the transport layer when a datagram, either unicast or multicast, has been 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. |
void |
send(OutgoingDatagramMessage msg)
Call this method to send a UDP datagram message. |
StreamResponseMessage |
send(StreamRequestMessage msg)
Call this method to send a TCP (HTTP) stream message. |
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 |
| Constructor Detail |
|---|
public SwitchableRouterImpl(UpnpServiceConfiguration configuration,
ProtocolFactory protocolFactory)
| Method Detail |
|---|
public UpnpServiceConfiguration getConfiguration()
getConfiguration in interface Routerpublic ProtocolFactory getProtocolFactory()
getProtocolFactory in interface Routerpublic boolean isEnabled()
isEnabled in interface SwitchableRouterpublic boolean enable()
enable in interface SwitchableRoutertrue if the router was enabled. false if it's already running.public void handleStartFailure(InitializationException ex)
SwitchableRouterSwitchableRouter.enable() method before it returns.
handleStartFailure in interface SwitchableRouterex - The cause of the failure.public boolean disable()
disable in interface SwitchableRoutertrue if the router was disabled. false if it wasn't running.public NetworkAddressFactory getNetworkAddressFactory()
getNetworkAddressFactory in interface Routerpublic List<NetworkAddress> getActiveStreamServers(InetAddress preferredAddress)
getActiveStreamServers in interface RouterpreferredAddress - A preferred stream server bound address or null.
public void shutdown()
Router
shutdown in interface Routerpublic void received(IncomingDatagramMessage msg)
RouterThis 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.
received in interface Routermsg - The received datagram message.public void received(UpnpStream stream)
RouterThis 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.
received in interface Routerpublic void send(OutgoingDatagramMessage msg)
RouterCall this method to send a UDP datagram message.
send in interface Routermsg - The UDP datagram message to send.public StreamResponseMessage send(StreamRequestMessage msg)
RouterCall this method to send a TCP (HTTP) stream message.
send in interface Routermsg - The TCP (HTTP) stream message to send.
public void broadcast(byte[] bytes)
RouterCall this method to broadcast a UDP message to all hosts on the network.
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 | |||||||||