Class RemoteResource

Definition

Namespace:
Tizen.Network.IoTConnectivity
Assembly:
Tizen.Network.IoTConnectivity.dll
API Level:
3

This class represents a remote resource. It provides APIs to manage remote resource.

C#
Copy
public class RemoteResource : IDisposable
Inheritance
System.Object
RemoteResource
Implements
System.IDisposable

Constructors

View Source

RemoteResource(String, String, ResourcePolicy, ResourceTypes, ResourceInterfaces)

Creates a remote resource instance.

Declaration
C#
Copy
public RemoteResource(string hostAddress, string uriPath, ResourcePolicy policy, ResourceTypes resourceTypes, ResourceInterfaces resourceInterfaces)
Parameters
Type Name Description
System.String hostAddress

The host address of the resource.

System.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.

OutOfMemoryException

Thrown when there is not enough memory.

System.ArgumentException

Thrown when there is an invalid parameter.

API Level: 3
Feature: http://tizen.org/feature/iot.ocf

Properties

View Source

CacheEnabled

Indicates the CacheEnabled status of the remote resource.

Declaration
C#
Copy
public bool CacheEnabled { get; set; }
Property Value
Type Description
Boolean

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.

UnauthorizedAccessException

Thrown when an application does not have privilege to access.

OutOfMemoryException

Thrown when there is not enough memory.

API Level: 3
View Source

DeviceId

The device ID of the resource.

Declaration
C#
Copy
public string DeviceId { get; }
Property Value
Type Description
System.String

The device ID of the resource.

API Level: 3
View Source

HostAddress

The host address of the resource.

Declaration
C#
Copy
public string HostAddress { get; }
Property Value
Type Description
System.String

The host address of the resource.

API Level: 3
View Source

Interfaces

The interfaces of the resource.

Declaration
C#
Copy
public IEnumerable<string> Interfaces { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

The interfaces of the resource.

API Level: 3
View Source

Options

The header options of the resource.

Declaration
C#
Copy
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.

API Level: 3
View Source

Policy

The policy of the resource.

Declaration
C#
Copy
public ResourcePolicy Policy { get; }
Property Value
Type Description
ResourcePolicy

The policy of the resource.

API Level: 3
View Source

TimeInterval

Time interval of monitoring and caching API.

Declaration
C#
Copy
public int TimeInterval { get; set; }
Property Value
Type Description
Int32

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.

API Level: 3
View Source

Types

The resource types of the remote resource.

Declaration
C#
Copy
public IEnumerable<string> Types { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.String>

The resource types of the remote resource.

API Level: 3
View Source

UriPath

The URI path of the resource.

Declaration
C#
Copy
public string UriPath { get; }
Property Value
Type Description
System.String

The URI path of the resource.

API Level: 3

Methods

View Source

CachedRepresentation()

Gets cached representation from the remote resource.

Declaration
C#
Copy
public Representation CachedRepresentation()
Returns
Type Description
Representation

cached representation from the remote resource.

API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

DeleteAsync()

Deletes the resource asynchronously.

Declaration
C#
Copy
public Task<RemoteResponse> DeleteAsync()
Returns
Type Description
System.Threading.Tasks.Task<RemoteResponse>

Remote response with result and representation.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
View Source

Dispose()

Releases any unmanaged resources used by this object.

Declaration
C#
Copy
public void Dispose()
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

Dispose(Boolean)

Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.

Declaration
C#
Copy
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

If true, disposes any disposable objects. If false, does not dispose disposable objects.

API Level: 3
Feature: http://tizen.org/feature/iot.ocf
View Source

Finalize()

Destructor of the RemoteResource class.

Declaration
C#
Copy
protected void Finalize()
View Source

GetAsync(ResourceQuery)

Gets the attributes of a resource asynchronously.

Declaration
C#
Copy
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<RemoteResponse>

Remote response with result and representation.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
View Source

PostAsync(Representation, ResourceQuery)

Posts request on a resource asynchronously.

Declaration
C#
Copy
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<RemoteResponse>

Remote response with result and representation.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
View Source

PutAsync(Representation, ResourceQuery)

Puts the representation of a resource asynchronously.

Declaration
C#
Copy
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<RemoteResponse>

Remote response with result and representation.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
View Source

StartObserving(ObservePolicy, ResourceQuery)

Starts observing on the resource.

Declaration
C#
Copy
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.

UnauthorizedAccessException

Thrown when an application does not have privilege to access.

OutOfMemoryException

Thrown when there is not enough memory.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
View Source

StopObserving()

Stops observing on the resource.

Declaration
C#
Copy
public void StopObserving()
Exceptions
Type Condition
System.NotSupportedException

Thrown when the iotcon is not supported.

System.InvalidOperationException

Thrown when the operation is invalid.

UnauthorizedAccessException

Thrown when an application does not have privilege to access.

API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf

Events

View Source

CacheUpdated

The event is invoked with cached resource attributes.

Declaration
C#
Copy
public event EventHandler<CacheUpdatedEventArgs> CacheUpdated
Event Type
Type Description
System.EventHandler<CacheUpdatedEventArgs>
API Level: 3
View Source

ObserverNotified

Observe an event on the resource sent by the server.

Declaration
C#
Copy
public event EventHandler<ObserverNotifiedEventArgs> ObserverNotified
Event Type
Type Description
System.EventHandler<ObserverNotifiedEventArgs>
API Level: 3
View Source

StateChanged

The event is called when remote resource's state are changed.

Declaration
C#
Copy
public event EventHandler<StateChangedEventArgs> StateChanged
Event Type
Type Description
System.EventHandler<StateChangedEventArgs>
API Level: 3

Implements

System.IDisposable