internal ServiceDiscoveryParams(BluetoothAddress address, Guid serviceGuid, SdpSearchScope searchScope) { this.address = address; this.serviceGuid = serviceGuid; if (searchScope != SdpSearchScope.Anywhere && searchScope != SdpSearchScope.ServiceClassOnly) { throw new ArgumentException("Unrecognized value for SdpSearchScope enum.", "searchScope"); } this.searchScope = searchScope; }
public IAsyncResult BeginServiceDiscovery(BluetoothAddress address, Guid serviceGuid, SdpSearchScope searchScope, AsyncCallback asyncCallback, Object state) { BeginServiceDiscoveryKillInquiry(); // Just in case the user modifies the original address!!! BluetoothAddress addr2 = (BluetoothAddress)address.Clone(); AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams> ar = new AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams>(asyncCallback, state, new ServiceDiscoveryParams(addr2, serviceGuid, searchScope)); lock (lockServiceDiscovery) { if (m_arServiceDiscovery != null) { throw new NotSupportedException("Currently support only one concurrent Service Lookup operation."); } bool success = false; try { m_arServiceDiscovery = ar; bool ret = m_btIf.StartDiscovery(addr2, serviceGuid); Debug.WriteLine(WidcommUtils.GetTime4Log() + ": StartDiscovery ret: " + ret); if (!ret) { WBtRc ee = GetExtendedError(); throw WidcommSocketExceptions.Create_StartDiscovery(ee); } success = true; } finally { if (!success) { m_arServiceDiscovery = null; } } } return(ar); }