ISensor.RegisterForNotification()

Description:

The RegisterForNotification method registers the client to receive data from one sensor channel.

This is an asynchronous method.

Syntax:

result = so.ISensor.RegisterForNotification(criteria, callback);

Arguments:

  • criteria:

    This is an object that specifies the sensor channel to listen for data. For more information about the object properties and how to define them, see section Criteria for receiving sensor data.

  • callback:

    The callback argument is the name of the method that is executed when a RegisterForNotification call has results or status information to return. You must define this method separately. Follow the instructions in section Defining the callback handler for an asynchronous method to define the callback method.

Return value:

The RegisterForNotification method returns an object that contains the initial return value for the asynchronous call it started (see the following table). The actual sensor data is returned by the callback method in the ReturnValue property of its result object. The returned data is described in section Returned sensor data.

Table: Return value properties for RegisterForNotification

Property

Description

Value

result.TransactionID

This is a number used as an identification to match transactions started with the RegisterForNotification call to one or more calls it generates to callback.

 

result.ErrorCode

This is a number that specifies a predefined error code.

See Service API error codes.

result.ErrorMessage

This is a text string that describes the error.

See Sensor Service API error messages.

Remarks:

  • RegisterForNotification retrieves sensor data until cancelled with Cancel.

  • Invoking the same call on the same sensor channel from the same user without cancelling the previous RegisterForNotification request results in an error, since the channel is already listening on the pre-registered notifications.

Example code:

For the complete source of a sample widget that demonstrates how to use this Service API, see the full example.