Skip to content

Resource

Jim Schaad edited this page Jun 29, 2017 · 1 revision

Resource Object

This class provides basic services for implementing a resource on a server.

The class inherits from IResource.

Properties

Attributes: Get the attribute set for the resource.

Cachable: Does the resource need to be searched for every time. I do not currently understand why this would ever be false.

Children: Return all of the child resources.

EndPoints: Retrieve the set of end points that the resource is bound to.

Executor: How are sub-tasks spawned off to be processed. Inherit behavior from the parent resource.

Name: Get/Set the name of the resource. Modifying the name of the resource changes the URI for this resource and all child resources.

Observable: Get/Set if the resource is observable.

ObserveType: What is the message type for notification messages. MessageType.Unknown means that both CON and NON will be used.

Parent: Get/Set the parent resource. Changing the parent will change the path to this resource and all child resources.

Path: Get/Set the path of the resource. The path does not include the name of the resource. Modifying the path of the resource changes the URI for this resource and all child resources.

RequireSecurity: Does the resource require security to execute? Security in this case means the use of DTLS or OSCOAP on the request message.

RequreSecurityErrorText: Response to return for any resource which requires security, but security has not been used.

Uri: Get/Set the URI of the resource.

Visible: Get/Set if the resource is visible to CoAP clients by discovery.

Methods

Add: Add a child resource to this node. Replaces a child resource of the same name.

AddObserveRelation: Add/Replace an observe relationship for this resource.

ClearObserveRelations: Remove all observe relationships on the resource.

ClearAndNotifyObserveRelations: Remove all observe relationships on the resource. It additionally sends a notification to all of the clients with a given status code.

Changed: Notify that all observers that a resource has been changed. Optional filter function can be used to only notify some observations.

Delete: Remove this resource from its parent. All observe relations on this and any children will be cleared and canceled.

DoDelete: Handle a delete request. Default handler responds with Method Not Allowed.

DoGet: Handle a get request. Default handler responds with Method Not Allowed.

DoPost: Handle a post request. Default handler responds with Method Not Allowed.

DoPut: Handle a put request. Default handler responds with Method Not Allowed.

GetChild: Retrieve a child resource based on its name.

HandleRequest: Execute the code for an incoming request. It will check the security requirement, returning an error if it is set and security is not present. It then dispatches to the appropriate function based on the request method.

Remove: Remove a resource from this node.

RemoveObserveRelation: Remove an observe relationship from the resource.

Clone this wiki locally