IPWorks IoT 2020 Python Edition

Questions / Feedback?

start_observing Method

Registers the class as an observer for a given resource.

Syntax

def start_observing(uri: str) -> str: ...

Remarks

This method registers the class as an observer for the resource identified by URI. If the server accepts the registration, then it will periodically notify the class about any changes to the specified resource. These "change notifications" are exposed via the on_notification event.

This method operates in the exact same manner as the get method, with the exception of the two things listed below. Refer to the get method's documentation for more information.

  1. When constructing the request, the class automatically includes an Observe option. The presence of this option is what indicates to the server that the class wishes to register itself as an observer for the specified resource.
  2. When the server receives the request, its response causes the on_notification event to fire instead of the on_request_complete event. (Unless it decides to reject the registration, in which case it will handle the request just like a normal GET request, and the on_request_complete event will fire when its response is received, just like it would if get had been called.)

Once the class has successfully registered itself as an observer, the server will continue to deliver change notifications for the specified resource until the class unregisters, or the resource can no longer be observed (e.g., if it is deleted). To unregister, either call the stop_observing method with the same URI value, or set the on_notification event's StopObserving parameter to True.

Note: This method can only be called when the class is operating in client mode (i.e., when the listening property is disabled).

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks IoT 2020 Python Edition - Version 20.0 [Build 8265]