Register Event

Fires when a client wishes to register for notifications.

Syntax

public event OnRegisterHandler OnRegister;

public delegate void OnRegisterHandler(object sender, CoapRegisterEventArgs e);

public class CoapRegisterEventArgs : EventArgs {
  public string RemoteHost { get; }
  public int RemotePort { get; }
  public string URI { get; }
  public string URIHost { get; }
  public int URIPort { get; }
  public string URIPath { get; }
  public string URIQuery { get; }
  public string Token { get; }
public byte[] TokenB { get; } public bool Accept { get; set; } }
Public Event OnRegister As OnRegisterHandler

Public Delegate Sub OnRegisterHandler(sender As Object, e As CoapRegisterEventArgs)

Public Class CoapRegisterEventArgs Inherits EventArgs
  Public ReadOnly Property RemoteHost As String
  Public ReadOnly Property RemotePort As Integer
  Public ReadOnly Property URI As String
  Public ReadOnly Property URIHost As String
  Public ReadOnly Property URIPort As Integer
  Public ReadOnly Property URIPath As String
  Public ReadOnly Property URIQuery As String
  Public ReadOnly Property Token As String
Public ReadOnly Property TokenB As Byte() Public Property Accept As Boolean End Class

Remarks

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

Any options included in the request can be obtained by querying the RequestOptions collection.

To correctly handle this event, populate the ResponseCode, ResponseData, ResponseContentFormat, ResponseETag, and ResponseOptions 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 SendNotification 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 component 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 component to add the client to its internal list of registered observers for the specified URI.

Note: This event is only used when the component 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 .NET Edition - Version 20.0 [Build 8265]