public class AndroidRouter extends RouterImpl
Modifier and Type | Field and Description |
---|---|
protected android.content.BroadcastReceiver |
broadcastReceiver |
protected android.net.wifi.WifiManager.MulticastLock |
multicastLock |
protected android.net.NetworkInfo |
networkInfo |
protected android.net.wifi.WifiManager.WifiLock |
wifiLock |
configuration, datagramIOs, enabled, multicastReceivers, networkAddressFactory, protocolFactory, readLock, routerLock, streamClient, streamServers, writeLock
Constructor and Description |
---|
AndroidRouter(UpnpServiceConfiguration configuration,
ProtocolFactory protocolFactory,
android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
protected android.content.BroadcastReceiver |
createConnectivityBroadcastReceiver() |
boolean |
disable()
Unbinds all sockets and stops all listening threads for datagrams and streams.
|
boolean |
enable()
Initializes listening services: First an instance of
MulticastReceiver
is bound to each network interface. |
boolean |
enableWiFi() |
protected int |
getLockTimeoutMillis() |
android.net.NetworkInfo |
getNetworkInfo() |
protected void |
handleRouterExceptionOnNetworkTypeChange(RouterException ex)
Handles errors when network has been switched, during reception of
network switch broadcast.
|
boolean |
isEthernet() |
boolean |
isMobile() |
boolean |
isWifi() |
protected void |
onNetworkTypeChange(android.net.NetworkInfo oldNetwork,
android.net.NetworkInfo newNetwork)
Can be overriden by subclasses to do additional work.
|
protected void |
setWifiLock(boolean enable) |
protected void |
setWiFiMulticastLock(boolean enable) |
void |
shutdown()
Disables the router and releases all other resources.
|
void |
unregisterBroadcastReceiver() |
broadcast, disable, enable, getActiveStreamServers, getConfiguration, getProtocolFactory, handleStartFailure, isEnabled, lock, lock, received, received, send, send, startAddressBasedTransports, startInterfaceBasedTransports, unlock
protected android.net.wifi.WifiManager.MulticastLock multicastLock
protected android.net.wifi.WifiManager.WifiLock wifiLock
protected android.net.NetworkInfo networkInfo
protected android.content.BroadcastReceiver broadcastReceiver
public AndroidRouter(UpnpServiceConfiguration configuration, ProtocolFactory protocolFactory, android.content.Context context) throws InitializationException
InitializationException
protected android.content.BroadcastReceiver createConnectivityBroadcastReceiver()
protected int getLockTimeoutMillis()
getLockTimeoutMillis
in class RouterImpl
public void shutdown() throws RouterException
Router
shutdown
in interface Router
shutdown
in class RouterImpl
RouterException
public boolean enable() throws RouterException
RouterImpl
MulticastReceiver
is bound to each network interface. Then an instance of DatagramIO
and
StreamServer
is bound to each bind address returned by the network
address factory, respectively. There is only one instance of
StreamClient
created and managed by this router.enable
in interface Router
enable
in class RouterImpl
true
if the router was enabled. false
if it's already running.RouterException
public boolean disable() throws RouterException
Router
disable
in interface Router
disable
in class RouterImpl
true
if the router was disabled. false
if it wasn't running.RouterException
public android.net.NetworkInfo getNetworkInfo()
public boolean isMobile()
public boolean isWifi()
public boolean isEthernet()
public boolean enableWiFi()
public void unregisterBroadcastReceiver()
protected void setWiFiMulticastLock(boolean enable)
protected void setWifiLock(boolean enable)
protected void onNetworkTypeChange(android.net.NetworkInfo oldNetwork, android.net.NetworkInfo newNetwork) throws RouterException
oldNetwork
- null
when first called by constructor.RouterException
protected void handleRouterExceptionOnNetworkTypeChange(RouterException ex)
Copyright © 2016 4th Line GmbH, Switzerland. All rights reserved.