Java Code Examples for javax.jmdns.JmDNS#close()

The following examples show how to use javax.jmdns.JmDNS#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmmDNSImpl.java    From DeviceConnect-Android with MIT License 6 votes vote down vote up
@Override
public void inetAddressRemoved(NetworkTopologyEvent event) {
    InetAddress address = event.getInetAddress();
    try {
        synchronized (this) {
            if (_knownMDNS.containsKey(address)) {
                JmDNS mDNS = _knownMDNS.remove(address);
                mDNS.close();
                final NetworkTopologyEvent jmdnsEvent = new NetworkTopologyEventImpl(mDNS, address);
                for (final NetworkTopologyListener listener : this.networkListeners()) {
                    _ListenerExecutor.submit(new Runnable() {
                        /**
                         * {@inheritDoc}
                         */
                        @Override
                        public void run() {
                            listener.inetAddressRemoved(jmdnsEvent);
                        }
                    });
                }
            }
        }
    } catch (Exception e) {
        logger.warning("Unexpected unhandled exception: " + e);
    }
}
 
Example 2
Source File: Core.java    From screenstandby with GNU General Public License v2.0 5 votes vote down vote up
private JmDNS setUpServer() {
     JmDNS jmdns = null;
     android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) context.getSystemService(android.content.Context.WIFI_SERVICE);
     lock = wifi.createMulticastLock("mylock");
     WifiInfo info = wifi.getConnectionInfo();
     _WifiName = info.getSSID();
     lock.setReferenceCounted(true);
     lock.acquire();
     try {
     	int intaddr = info.getIpAddress();
     	byte[] byteaddr = new byte[] { (byte) (intaddr & 0xff), (byte) (intaddr >> 8 & 0xff), (byte) (intaddr >> 16 & 0xff), (byte) (intaddr >> 24 & 0xff) };
     	InetAddress addr=InetAddress.getByAddress(byteaddr); //Need to process UnknownHostException
     	_IP = intToIp(intaddr);
     	jmdns=JmDNS.create(addr);
 		serviceInfo = ServiceInfo.create(type, getDeviceName(), SERVICE_PORT, "SS Remote");
java.util.HashMap<String,String> mProp = new java.util.HashMap<String,String>();

//if device has a big screen and cannot make call, it is a tablet
mProp.put("bTab", (this.context.getResources().getBoolean(R.bool.isTablet) && !canDeviceMakeCall())+"");
mProp.put("sHost", android.os.Build.HOST);
serviceInfo.setText(mProp);
     	if (isServerMode) jmdns.registerService(serviceInfo);
     	else jmdns.close();
     } catch (IOException e) {
         Logger.Log(context, e);
     }
     return jmdns;
 }
 
Example 3
Source File: MDNSClientImpl.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
private void closeQuietly(JmDNS jmdns) {
    try {
        jmdns.close();
    } catch (IOException e) {
    }
}
 
Example 4
Source File: MDNSClientImpl.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
private void closeQuietly(JmDNS jmdns) {
    try {
        jmdns.close();
    } catch (IOException e) {
    }
}
 
Example 5
Source File: ZeroConf.java    From cordova-plugin-zeroconf with MIT License 3 votes vote down vote up
public void stop() throws IOException {

            for (JmDNS publisher : publishers) {
                publisher.close();
            }

        }
 
Example 6
Source File: ZeroConf.java    From cordova-plugin-zeroconf with MIT License 3 votes vote down vote up
private void close() throws IOException {

            lock.release();

            callbacks.clear();

            for (JmDNS browser : browsers) {
                browser.close();
            }

        }