Clients that make service and attribute queries through CSdpAgent must
implement the MSdpAgentNotifier interface
to handle the responses.
There are two kinds of results that require handling, they are:
We will examine a simple handling example for both kinds below.
Note: Queries are asynchronous.
When a service
search request completes, it calls the NextRecordRequestComplete():
virtual void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount)
aHandle gives the service record handle of the matching
service, and can be used in a subsequent attribute query. aTotalRecordsCount gives
the total number of matching records.
When an attribute
request completes, each single attribute is returned with its attribute ID
using AttributeRequestResult().
virtual void AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue)
The ID of the attribute is given in aAttrID, and the
attribute value itself in aAttrValue. You can find the type
of the attribute through aAttrValue->Type(), cast aAttrValue on
this base to the correct subclass of CSdpAttrValue:
for example, if the type is ETypeBoolean,
you can cast aAttrValue to a CSdpAttrValueBoolean.
When
there are no more attributes to be returned, AttributeRequestComplete() is
called.
The complete set of Service Discovery Agent tutorials are shown below:
Also refer to the Bluetooth Service Discovery Agent Overview and the Bluetooth SDP Overview for additional background information.