Beispiel #1
0
        protected override void OnStop()
        {
            if (_jmdns != null)
            {
                if (_listener != null)
                {
                    _jmdns.RemoveServiceListener(_type, _listener);
                    _listener = null;
                }
                _jmdns.UnregisterAllServices();
                try
                {
                    _jmdns.Close();
                }
                catch (IOException e)
                {
                    // TODO Auto-generated catch block
                    e.PrintStackTrace();
                }
                _jmdns = null;
            }
            //repo.stop();
            //s.stop();

            _lock.Release();
            base.OnStop();
        }
Beispiel #2
0
        public void Setup()
        {
            Android.Net.Wifi.WifiManager wifi = GetSystemService(Android.Content.Context.WifiService) as Android.Net.Wifi.WifiManager;

            _lock = wifi.CreateMulticastLock("mylockthereturn");
            _lock.SetReferenceCounted(true);
            _lock.Acquire();
            try
            {
                _jmdns    = JmDNS.Create();
                _listener = new MyServiceListener(this);
                _jmdns.AddServiceListener(_type, _listener);
                _serviceInfo = ServiceInfo.Create("_test._tcp.local.", "AndroidTest", 0, "plain test service from android");
                _jmdns.RegisterService(_serviceInfo);
            }
            catch (IOException e)
            {
                e.PrintStackTrace();
                return;
            }
        }