public override List <int> EndServiceDiscovery(IAsyncResult ar) { using (ISdpDiscoveryRecordsBuffer recBuf = BtIf.EndServiceDiscovery(ar)) { var portList = new List <int>(); int[] ports = recBuf.Hack_GetPsms(); Utils.MiscUtils.Trace_WriteLine("_GetPorts, got {0} records.", recBuf.RecordCount); #if DEBUG if (ports.Length == 0) { Math.Abs(1); // COVERAGE } else { Math.Abs(1); // COVERAGE } #endif // Do this in reverse order, as Widcomm appears to keep old // (out of date!!) service records around, so we want to // use the newests ones in preference. for (int i = ports.Length - 1; i >= 0; --i) { int cur = ports[i]; portList.Add(cur); }//for return(portList); } }
private ISdpDiscoveryRecordsBuffer EndGetServiceRecordsUnparsedWidcomm(IAsyncResult ar) { WidcommBtInterface iface = m_factory.GetWidcommBtInterface(); ISdpDiscoveryRecordsBuffer wrec = iface.EndServiceDiscovery(ar); return(wrec); }
public ServiceRecord[] EndGetServiceRecords(IAsyncResult asyncResult) { using (ISdpDiscoveryRecordsBuffer wrec = EndGetServiceRecordsUnparsedWidcomm(asyncResult)) { ServiceRecord[] records = wrec.GetServiceRecords(); return(records); } }
public ISdpDiscoveryRecordsBuffer WidcommHack__GetServiceRecordsUnparsed(BluetoothAddress address, Guid serviceGuid) { WidcommBtInterface btIf = ((WidcommBluetoothClient)m_impl).m_btIf___HACK; IAsyncResult ar = btIf.BeginServiceDiscovery(address, serviceGuid, null, null); ISdpDiscoveryRecordsBuffer recs = btIf.EndServiceDiscovery(ar); return(recs); }
static void RaiseDiscoveryComplete( AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams> sacAr, ISdpDiscoveryRecordsBuffer recBuf, Exception sacEx) { if (sacAr != null) // will always be true! { if (sacEx != null) { sacAr.SetAsCompleted(sacEx, false); } else { sacAr.SetAsCompleted(recBuf, false); } } }
internal void HandleDiscoveryComplete() { Utils.MiscUtils.Trace_WriteLine("HandleDiscoveryComplete"); AsyncResult <ISdpDiscoveryRecordsBuffer, ServiceDiscoveryParams> sacAr = null; ISdpDiscoveryRecordsBuffer recBuf = null; Exception sacEx = null; try { lock (lockServiceDiscovery) { Debug.Assert(m_arServiceDiscovery != null, "NOT m_arServiceDiscovery != null"); if (m_arServiceDiscovery == null) { return; } // Nothing we can do then! sacAr = m_arServiceDiscovery; m_arServiceDiscovery = null; BluetoothAddress addr; ushort numRecords0; DISCOVERY_RESULT result = m_btIf.GetLastDiscoveryResult(out addr, out numRecords0); if (result != DISCOVERY_RESULT.SUCCESS) { sacEx = WidcommSocketExceptions.Create(result, "ServiceRecordsGetResult"); return; } if (!addr.Equals(sacAr.BeginParameters.address)) { sacEx = new InvalidOperationException("Internal error -- different DiscoveryComplete address."); return; } // Get the records recBuf = m_btIf.ReadDiscoveryRecords(addr, MaxNumberSdpRecords, sacAr.BeginParameters); }//lock } catch (Exception ex) { sacEx = ex; } finally { Debug.Assert(sacAr != null, "out: NOT sacAr != null"); Debug.Assert(m_arServiceDiscovery == null, "out: NOT m_arServiceDiscovery == null"); WaitCallback dlgt = delegate { RaiseDiscoveryComplete(sacAr, recBuf, sacEx); }; ThreadPool.QueueUserWorkItem(dlgt); } }