ã¡ãã£ã¨æ°ã«ãªã£ã¦ãã£ã¦ã¿ããç°¡åã«ã§ãããNuGet ãã Zeroconf å ¥ããã ããã©ã¤ã»ã³ã¹ã¯ Ms-PLã
ãã®ã©ã¤ãã©ãªã¯ZeroconfResolver
ã¨ããã¯ã©ã¹ãæä¾ãã¦ãã¦ãã¡ã½ããã¯ResolveAsync
ã¨BrowseDomainsAsync
ã¨ããstaticãªã¡ã½ãããæä¾ãã¦ãããã¢ããªã®ããã¸ã§ã¯ãã«ãããã±ã¼ã¸ã追å ãã¦ããã°ãPCL ããã使ããã
Android ã®å ´åã¯ã[assembly: UsesPermission(Manifest.Permission.ChangeWifiMulticastState)]
ãæ¸ãã¦ããå¿
è¦ããã
ãµã³ãã«ã³ã¼ãã¨ã㦠MvvmCross ã§ä½¿ç¨ããã¨ãã® ViewModel ã ãã¯ã£ã¦ããã
using System; using System.Linq; using System.Collections.Generic; using Cirrious.MvvmCross.ViewModels; using Zeroconf; namespace ZeroconfTest.Core.ViewModels { public class FirstViewModel : MvxViewModel { async void Lookup() { BonjourItems = (await ZeroconfResolver.ResolveAsync("_raop._tcp.local.", TimeSpan.FromSeconds(15))) .Select(zi => new BonjourItem(zi)) .ToList(); } #region Properties public List<BonjourItem> BonjourItems { get { return _bonjourItems; } set { _bonjourItems = value; RaisePropertyChanged(() => BonjourItems); } } List<BonjourItem> _bonjourItems; #endregion #region Commands public MvxCommand LookupCommand { get { return _lookupCommand ?? (_lookupCommand = new MvxCommand(Lookup)); } } MvxCommand _lookupCommand; #endregion public class BonjourItem { internal BonjourItem(IZeroconfHost host) { Id = host.Id; DisplayName = host.DisplayName; IPAddress = host.IPAddress; } public string Id { get; private set; } public string DisplayName { get; private set; } public string IPAddress { get; private set; } public override string ToString() { return string.Format("{0} ({1})", DisplayName, IPAddress); } } } }
Android ã ã¨ããã¨ããæãã«åãã¦ããã£ã½ããã©ãiOS ã ã¨çµæ§æ¬ è½ããå°è±¡ããããä¸èº« Apple ã®å®è£ ã«ç½®ãæããæ¹ãããã®ããã