public Task StartScanning() { var isWifiEnabled = NetworkInterfaces.IsWifiEnabled(); if (!isWifiEnabled) { throw new WiFiTurnedOffException(); } var myPeerId = new MCPeerID(UIDevice.CurrentDevice.Name); _session = new MCSession(myPeerId) { Delegate = new SessionDelegate(this) }; MainThread.BeginInvokeOnMainThread(() => { var browser = new MCNearbyServiceBrowser(myPeerId, BluetoothOperator.CROSSCAM_SERVICE) { Delegate = new NewBrowserDelegate(this) }; browser.StartBrowsingForPeers(); }); Debug.WriteLine("### SCANNING START"); return(Task.FromResult(true)); }
public Task BecomeDiscoverable() { var isWifiEnabled = NetworkInterfaces.IsWifiEnabled(); if (!isWifiEnabled) { throw new WiFiTurnedOffException(); } var myPeerId = new MCPeerID(UIDevice.CurrentDevice.Name); _session = new MCSession(myPeerId) { Delegate = new SessionDelegate(this) }; var assistant = new MCAdvertiserAssistant(BluetoothOperator.CROSSCAM_SERVICE, new NSDictionary(), _session); assistant.Start(); Debug.WriteLine("### DISCOVERABLE START"); return(Task.FromResult(true)); }