IPWorks IoT 2020 Python Edition

Questions / Feedback?

on_register Event

Fires when a client wishes to register for notifications.

Syntax

class CoAPRegisterEventParams(object):
  @property
  def remote_host() -> str: ...
  @property
  def remote_port() -> int: ...
  @property
  def uri() -> str: ...
  @property
  def uri_host() -> str: ...
  @property
  def uri_port() -> int: ...
  @property
  def uri_path() -> str: ...
  @property
  def uri_query() -> str: ...
  @property
  def token() -> bytes: ...
  @property
  def accept() -> bool: ...
  @accept.setter
  def accept(value) -> None: ...

# In class CoAP:
@property
def on_register() -> Callable[[CoAPRegisterEventParams], None]: ...
@on_register.setter
def on_register(event_hook: Callable[[CoAPRegisterEventParams], None]) -> None: ...

Remarks

This event fires anytime a client wishes to register itself as an observer for the resource identified by URI. Refer to the start_observing and send_notification methods, as well as the on_notification event, for more information about observing resources and resource change notifications.

Any options included in the request can be obtained by querying the RequestOption* properties.

To correctly handle this event, populate the response_code, response_data, response_content_format, response_e_tag, and ResponseOption* properties as desired before this event finishes. (This must be done regardless of the Accept parameter's final value; see below for more information on why).

The RemoteHost parameter reflects the client's IP address or hostname.

The RemotePort parameter reflects the client's port.

The URI parameter reflects the exact resource URI that the client wishes to observe (the CoAP specification states that the full URI must be used to track observers). This value must be passed exactly as-is to the send_notification method to notify observers of changes to the resource.

The URIHost, URIPort, URIPath, and URIQuery parameters are provided for additional convenience

The Token parameter reflects the token included in the registration request.

The Accept parameter specifies whether the class should accept the registration. By default, it is False, and the request will be treated like a normal GET request. Setting it to True will cause the class to add the client to its internal list of registered observers for the specified URI.

Note: This event is only used when the class is operating in server mode (i.e., when the listening property is enabled).

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