Class RemoteResource
Definition
- Namespace:
- Tizen.Network.IoTConnectivity
- Assembly:
- Tizen.Network.IoTConnectivity.dll
This class represents a remote resource. It provides APIs to manage remote resource.
public class RemoteResource : IDisposable
- Inheritance
-
objectRemoteResource
- Implements
-
System.IDisposable
Constructors
View SourceRemoteResource(string, string, ResourcePolicy, ResourceTypes, ResourceInterfaces)
Creates a remote resource instance.
Declaration
public RemoteResource(string hostAddress, string uriPath, ResourcePolicy policy, ResourceTypes resourceTypes, ResourceInterfaces resourceInterfaces)
Parameters
Type | Name | Description |
---|---|---|
string | hostAddress | The host address of the resource. |
string | uriPath | The URI path of the resource. |
ResourcePolicy | policy | The policies of the resource. |
ResourceTypes | resourceTypes | The resource types of the resource. |
ResourceInterfaces | resourceInterfaces | The resource interfaces of the resource. |
Remarks
To use this API, you should provide all the details required to correctly contact and observe the object.
If not, you should discover the resource object manually.
The policy
can contain multiple policies like ResourcePolicy.Discoverable | ResourcePolicy.Observable
.
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.OutOfMemoryException | Thrown when there is not enough memory. |
System.ArgumentException | Thrown when there is an invalid parameter. |
Properties
View SourceCacheEnabled
Indicates the CacheEnabled status of the remote resource.
Declaration
public bool CacheEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool | Client can start caching only when this is set true. Set it to false to stop caching the resource attributes. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.ArgumentException | Thrown when there is an invalid parameter. |
System.InvalidOperationException | Thrown when the operation is invalid. |
System.UnauthorizedAccessException | Thrown when an application does not have privilege to access. |
System.OutOfMemoryException | Thrown when there is not enough memory. |
DeviceId
The device ID of the resource.
Declaration
public string DeviceId { get; }
Property Value
Type | Description |
---|---|
string | The device ID of the resource. |
HostAddress
The host address of the resource.
Declaration
public string HostAddress { get; }
Property Value
Type | Description |
---|---|
string | The host address of the resource. |
Interfaces
The interfaces of the resource.
Declaration
public IEnumerable<string> Interfaces { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><string> | The interfaces of the resource. |
Options
The header options of the resource.
Declaration
public ResourceOptions Options { get; set; }
Property Value
Type | Description |
---|---|
ResourceOptions | The header options of the resource. |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.ArgumentException | Thrown when there is an invalid parameter. |
Policy
The policy of the resource.
Declaration
public ResourcePolicy Policy { get; }
Property Value
Type | Description |
---|---|
ResourcePolicy | The policy of the resource. |
TimeInterval
Time interval of monitoring and caching API.
Declaration
public int TimeInterval { get; set; }
Property Value
Type | Description |
---|---|
int | Default time interval is 10 seconds. Seconds for time interval (must be in range from 1 to 3600). |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.ArgumentException | Thrown when there is an invalid parameter. |
Types
The resource types of the remote resource.
Declaration
public IEnumerable<string> Types { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T><string> | The resource types of the remote resource. |
UriPath
The URI path of the resource.
Declaration
public string UriPath { get; }
Property Value
Type | Description |
---|---|
string | The URI path of the resource. |
Methods
View SourceCachedRepresentation()
Gets cached representation from the remote resource.
Declaration
public Representation CachedRepresentation()
Returns
Type | Description |
---|---|
Representation | cached representation from the remote resource. |
DeleteAsync()
Deletes the resource asynchronously.
Declaration
public Task<RemoteResponse> DeleteAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><RemoteResponse> | Remote response with result and representation. |
Dispose()
Releases any unmanaged resources used by this object.
Declaration
public void Dispose()
Dispose(bool)
Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | If true, disposes any disposable objects. If false, does not dispose disposable objects. |
~RemoteResource()
Destructor of the RemoteResource class.
Declaration
protected ~RemoteResource()
GetAsync(ResourceQuery)
Gets the attributes of a resource asynchronously.
Declaration
public Task<RemoteResponse> GetAsync(ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
ResourceQuery | query | The ResourceQuery to send to server. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><RemoteResponse> | Remote response with result and representation. |
PostAsync(Representation, ResourceQuery)
Posts request on a resource asynchronously.
Declaration
public Task<RemoteResponse> PostAsync(Representation representation, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
Representation | representation | Resource representation of request. |
ResourceQuery | query | The ResourceQuery to send to server. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><RemoteResponse> | Remote response with result and representation. |
PutAsync(Representation, ResourceQuery)
Puts the representation of a resource asynchronously.
Declaration
public Task<RemoteResponse> PutAsync(Representation representation, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
Representation | representation | Resource representation to put. |
ResourceQuery | query | The ResourceQuery to send to server. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TResult><RemoteResponse> | Remote response with result and representation. |
StartObserving(ObservePolicy, ResourceQuery)
Starts observing on the resource.
Declaration
public void StartObserving(ObservePolicy policy, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
ObservePolicy | policy | The type to specify how client wants to observe. |
ResourceQuery | query | The query to send to server. |
Remarks
When server sends notification message, ObserverNotified will be called.
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.InvalidOperationException | Thrown when the operation is invalid. |
System.UnauthorizedAccessException | Thrown when an application does not have privilege to access. |
System.OutOfMemoryException | Thrown when there is not enough memory. |
StopObserving()
Stops observing on the resource.
Declaration
public void StopObserving()
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.InvalidOperationException | Thrown when the operation is invalid. |
System.UnauthorizedAccessException | Thrown when an application does not have privilege to access. |
Events
View SourceCacheUpdated
The event is invoked with cached resource attributes.
Declaration
public event EventHandler<CacheUpdatedEventArgs> CacheUpdated
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><CacheUpdatedEventArgs> |
ObserverNotified
Observe an event on the resource sent by the server.
Declaration
public event EventHandler<ObserverNotifiedEventArgs> ObserverNotified
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><ObserverNotifiedEventArgs> |
StateChanged
The event is called when remote resource's state are changed.
Declaration
public event EventHandler<StateChangedEventArgs> StateChanged
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><StateChangedEventArgs> |