コード例 #1
0
 internal void InitNetBrowser ()
 {
     _serviceList = new List<NSNetService> ();
     _netBrowser = new NSNetServiceBrowser ();
     
     _source = new ServicesTableSource (this);
     servicesTable.Source = _source;
     
     _netBrowser.SearchForServices ("_bonjourdemoservice._tcp", "");
     
     _netBrowser.FoundService += delegate(object sender, NSNetServiceEventArgs e) {
         logView.AppendTextLine (String.Format ("{0} added", e.Service.Name));
         
         _serviceList.Add (e.Service);
         
         e.Service.AddressResolved += ServiceAddressResolved;
         
         // NOTE: could also insert and remove rows in a
         // more fine grained fashion here as well
         servicesTable.ReloadData ();
     };
     
     _netBrowser.ServiceRemoved += delegate(object sender, NSNetServiceEventArgs e) {
         logView.AppendTextLine (String.Format ("{0} removed", e.Service.Name));
         
         var nsService = _serviceList.Single (s => s.Name.Equals (e.Service.Name));
         _serviceList.Remove (nsService);
         servicesTable.ReloadData ();
     };
 }
コード例 #2
0
        internal void InitNetBrowser()
        {
            _serviceList = new List <NSNetService> ();
            _netBrowser  = new NSNetServiceBrowser();

            _source = new ServicesTableSource(this);
            servicesTable.Source = _source;

            _netBrowser.SearchForServices("_bonjourdemoservice._tcp", "");

            _netBrowser.FoundService += delegate(object sender, NSNetServiceEventArgs e) {
                logView.AppendTextLine(String.Format("{0} added", e.Service.Name));

                _serviceList.Add(e.Service);

                e.Service.AddressResolved += ServiceAddressResolved;

                // NOTE: could also insert and remove rows in a
                // more fine grained fashion here as well
                servicesTable.ReloadData();
            };

            _netBrowser.ServiceRemoved += delegate(object sender, NSNetServiceEventArgs e) {
                logView.AppendTextLine(String.Format("{0} removed", e.Service.Name));

                var nsService = _serviceList.Single(s => s.Name.Equals(e.Service.Name));
                _serviceList.Remove(nsService);
                servicesTable.ReloadData();
            };
        }
コード例 #3
0
		public override void FoundService (NSNetServiceBrowser sender, NSNetService service, bool moreComing)
		{
			Debug.WriteLine (String.Format("Found {0}", service.Name));

			if (service.Name.Equals ("Calabash Server"))
			if (successCallback != null)
				successCallback ();
		}
コード例 #4
0
 public AutoServerDicovery(UITableViewControllerServerDiscovery parent)
 {
     // Setup of the service browser.
     Browser  = new NSNetServiceBrowser();
     Delegate = new ServerDelegate(parent);
     Browser.Init();
     Browser.Delegate = Delegate;
 }
コード例 #5
0
 public override void FoundService(NSNetServiceBrowser sender,
                                   NSNetService service, bool moreComing)
 {
     Console.WriteLine("Found service " + service.HostName);
     Services.Add(service);
     if (!moreComing)
     {
         UpdateUI();
     }
 }
コード例 #6
0
ファイル: NetworkDiscovery.cs プロジェクト: AngelOD/jet-banjo
 public void OnAppStart()
 {
     serviceBrowser = new NSNetServiceBrowser();
     serviceBrowser.FoundService   += OnServiceFound;
     serviceBrowser.ServiceRemoved += OnServiceLost;
     serviceBrowser.SearchStarted  += OnServiceStarted;
     serviceBrowser.SearchStopped  += OnServiceStopped;
     serviceBrowser.NotSearched    += OnServiceNotSearched;
     serviceBrowser.Schedule(NSRunLoop.Current, NSRunLoopMode.Default.ToString());
     serviceBrowser.SearchForServices(Constants.NETWORK_SEARCH, "local");
 }
コード例 #7
0
        public override void FoundService(NSNetServiceBrowser sender, NSNetService service, bool moreComing)
        {
            Debug.WriteLine(String.Format("Found {0}", service.Name));

            if (service.Name.Equals("Calabash Server"))
            {
                if (successCallback != null)
                {
                    successCallback();
                }
            }
        }
コード例 #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _browserDelegate = new BonjourBrowser();
            _browserDelegate.successCallback += () => {
                statusLabel.Text = "Calabash is running!";
                _browser.Stop();
            };

            _browser          = new NSNetServiceBrowser();
            _browser.Delegate = _browserDelegate;
            _browser.SearchForServices("_http._tcp.", "local.");
        }
コード例 #9
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			_browserDelegate = new BonjourBrowser ();
			_browserDelegate.successCallback += ()=> {
				statusLabel.Text = "Calabash is running!";
				_browser.Stop();
			};

			_browser = new NSNetServiceBrowser ();
			_browser.Delegate = _browserDelegate;
			_browser.SearchForServices ("_http._tcp.", "local.");
		}
コード例 #10
0
 static void Enable()
 {
     enabled = true;
     if (browser == null) {
         browser = new NSNetServiceBrowser ();
         browser.FoundService += delegate (object sender, NSNetServiceEventArgs e) {
             if (services == null)
                 services = new ConcurrentDictionary<string, NSNetService> ();
             var service = e.Service;
     #if DEBUG
             service.AddressResolved += (sender2, e2) => {
                 var s = sender2 as NSNetService;
                 Debug.WriteLine ("{0} {1}:{2}", s.Name, s.HostName, s.Port);
             };
     #endif
             service.Resolve (2.0d);
             services.TryAdd (service.Name, service);
         };
         browser.ServiceRemoved += delegate (object sender, NSNetServiceEventArgs e) {
             string name = e.Service.Name;
             if (!String.IsNullOrEmpty (name)) {
                 NSNetService service;
                 services.TryRemove (name, out service);
             }
         };
     }
     browser.SearchForServices ("_airplay._tcp", "local.");
 }
コード例 #11
0
        public override void ServiceRemoved(NSNetServiceBrowser sender, NSNetService service, bool moreComing)
        {
            nint idx = (nint)Services.IndexOf(service);

            Services.RemoveObject(idx);
        }
コード例 #12
0
 public override void NotSearched(NSNetServiceBrowser sender, NSDictionary errors)
 {
     Searching = false;
     HandleError(errors);
 }
コード例 #13
0
 public override void SearchStopped(NSNetServiceBrowser sender)
 {
     Console.WriteLine("Started stopped");
     Searching = false;
     UpdateUI();
 }
コード例 #14
0
 protected override void Initialize()
 {
     browser = new NSNetServiceBrowser();
 }