Class IoTConnectivityClientManager
Definition
- Namespace:
- Tizen.Network.IoTConnectivity
- Assembly:
- Tizen.Network.IoTConnectivity.dll
- API Level:
- 3
IoT connectivity client manager consists of client side APIs.
C#Copypublic static class IoTConnectivityClientManager
- Inheritance
-
System.ObjectIoTConnectivityClientManager
Fields
Declaration
C#Copypublic const string MulticastAddress = null
Field Value
Type | Description |
---|---|
System.String |
API Level: 3
Properties
Declaration
C#Copypublic static int PollingInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | Sets/Gets the polling inerval(milliseconds) of IoTCon. Default value is 100 milliseconds. Value to be set must be in range from 1 to 999. The closer to 0, the faster it operates. Setter is invoked immediately for changing the interval. If you want the faster operation, we recommend you set 10 milliseconds for polling interval. Setter can throw exception. |
Examples
CopyIoTConnectivityClientManager.Initialize(); IoTConnectivityClientManager.PollingInterval = 100;
API Level: 3
Precondition: Initialize() should be called to initialize.
Declaration
C#Copypublic static int TimeOut { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | Value to be set must be in range from 1 to 3600. Default timeout interval value is 30. Sets/gets the timeout of StartFindingResource(), StartFindingDeviceInformation(), StartFindingPlatformInformation(), RemoteResource.GetAsync(), RemoteResource.PutAsync(), RemoteResource.PostAsync() and RemoteResource.DeleteAsync() APIs. Setter can throw exception. |
Examples
CopyIoTConnectivityClientManager.Initialize(); IoTConnectivityClientManager.TimeOut = 120;
API Level: 3
Precondition: Initialize() should be called to initialize.
Methods
Declaration
C#Copypublic static void Deinitialize()
Remarks
This API must be called if IoTCon API is no longer needed.
Examples
CopyIoTConnectivityClientManager.Deinitialize();
See Also
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Precondition: Initialize() should be called to initialize.
Declaration
C#Copypublic static void Initialize(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | The file path pointing to storage for handling secure virtual resources. |
Remarks
filePath
points to a file for handling secure virtual resources.
The file that is CBOR(Concise Binary Object Representation)-format must already exist
in filePath
. We recommend to use application-local file for filePath
.
Examples
Copystring filePath = "../../res/iotcon-test-svr-db-client.dat"; IoTConnectivityClientManager.Initialize(filePath);
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.ArgumentException | Thrown when there is an invalid parameter. |
UnauthorizedAccessException | Thrown when an application does not have privilege to access. |
See Also
API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/network.gethttp://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
Postcondition: You must call Deinitialize() if IoTCon API is no longer needed.
InvokePolling()
Invokes a next message from a queue for receiving messages from others, immediately.
Declaration
C#Copypublic static void InvokePolling()
Remarks
This API invokes a next message from a queue for receiving messages from others, immediately. After calling the API, it continues the polling with existing interval.
Examples
CopyIoTConnectivityClientManager.InvokePolling();
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
API Level: 3
Feature: http://tizen.org/feature/iot.ocf
Precondition: Initialize() should be called to initialize.
StartFindingDeviceInformation(String, ResourceQuery)
Starts finding the device information of remote server.
Declaration
C#Copypublic static int StartFindingDeviceInformation(string hostAddress, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | hostAddress | The host address of the remote server. |
ResourceQuery | query | The query specified as a filter for founding resources. |
Returns
Type | Description |
---|---|
System.Int32 | RequestId - An identifier for this request. |
Remarks
Requests server for device information. If succeeded, DeviceInformationFound event handler will be triggered with information of the device.
hostAddress
could be MulticastAddress for the IPv4 multicast.
Examples
CopyEventHandler<DeviceInformationFoundEventArgs> handler = (sender, e) => { Console.Log("Device information found, id : " + e.RequestId + ", name : " + e.Name); } EventHandler<FindingErrorOccurredEventArgs> errorHandler = (sender, e) => { Console.Log("Found error :" + e.Error.Message); } IoTConnectivityClientManager.DeviceInformationFound += handler; IoTConnectivityClientManager.FindingErrorOccurred += errorHandler; // Do not forget to remove these event handlers when they are not required any more. int id = IoTConnectivityClientManager.StartFindingDeviceInformation(IoTConnectivityClientManager.MulticastAddress);
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
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
Precondition: Initialize() should be called to initialize.
Postcondition: event handler will be invoked.
StartFindingPlatformInformation(String, ResourceQuery)
Starts finding the platform information of remote server.
Declaration
C#Copypublic static int StartFindingPlatformInformation(string hostAddress, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | hostAddress | The host address of remote server. |
ResourceQuery | query | The query specified as a filter for founding resources. |
Returns
Type | Description |
---|---|
System.Int32 | RequestId - An identifier for this request. |
Remarks
Requests server for platform information. If succeeded, PlatformInformationFound event handler will be triggered with information of the platform.
hostAddress
could be MulticastAddress for IPv4 multicast.
Examples
CopyEventHandler<PlatformInformationFoundEventArgs> handler = (sender, e) => { Console.Log("PlatformInformationFound :" + e.RequestId); } EventHandler<FindingErrorOccurredEventArgs> errorHandler = (sender, e) => { Console.Log("Found error :" + e.Error.Message); } IoTConnectivityClientManager.PlatformInformationFound += handler; IoTConnectivityClientManager.FindingErrorOccurred += errorHandler; // Do not forget to remove these event handlers when they are not required any more. int id = IoTConnectivityClientManager.StartFindingPlatformInformation(IoTConnectivityClientManager.MulticastAddress);
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
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
Precondition: Initialize() should be called to initialize.
Postcondition: event handler will be invoked.
Declaration
C#Copypublic static int StartFindingResource(string hostAddress, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | hostAddress | The address or addressable name of the server. The address includes a protocol like coaps://. |
ResourceQuery | query | The query specified as a filter for founding resources. |
Returns
Type | Description |
---|---|
System.Int32 | RequestId - An identifier for this request. |
Remarks
Sends request to find a resource of hostAddress
server with query
.
If succeeded, ResourceFound event handler will be triggered with information of the resource.
hostAddress
could be MulticastAddress for the IPv4 multicast.
Examples
CopyEventHandler<ResourceFoundEventArgs> handler = (sender, e) => { Console.Log("Found resource at host address :" + e.Resource.HostAddress + ", uri :" + e.Resource.UriPath); } EventHandler<FindingErrorOccurredEventArgs> errorHandler = (sender, e) => { Console.Log("Found error :" + e.Error.Message); } IoTConnectivityClientManager.ResourceFound += handler; IoTConnectivityClientManager.FindingErrorOccurred += errorHandler; ResourceQuery query = new ResourceQuery(); query.Type = "oic.iot.door"; // Do not forget to remove these event handlers when they are not required any more. int id = IoTConnectivityClientManager.StartFindingResource(null, query);
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
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
Precondition: Initialize() should be called to initialize.
Postcondition: When the resource is found, event handler will be invoked.
Declaration
C#Copypublic static int StartReceivingPresence(string hostAddress, string resourceType)
Parameters
Type | Name | Description |
---|---|---|
System.String | hostAddress | The address or addressable name of the server. |
System.String | resourceType | A resource type that a client is interested in. |
Returns
Type | Description |
---|---|
System.Int32 | PresenceId - An identifier for this request. |
Remarks
Sends request to receive presence to an interested server's resource with resourceType. If succeeded, PresenceReceived event handler will be triggered when the server sends presence. A server sends presence events when adds / removes / alters a resource or start / stop presence.
hostAddress
could be MulticastAddress for IPv4 multicast.
The length of resourceType
should be less than or equal to 61.
The resourceType
must start with a lowercase alphabetic character, followed by a sequence
of lowercase alphabetic, numeric, ".", or "-" characters, and contains no white space.
Examples
CopyEventHandler<PresenceReceivedEventArgs> handler = (sender, e) => { Console.Log("PresenceReceived, presence id :" + e.PresenceId); } EventHandler<FindingErrorOccurredEventArgs> errorHandler = (sender, e) => { Console.Log("Found error :" + e.Error.Message); } IoTConnectivityClientManager.PresenceReceived += handler; IoTConnectivityClientManager.FindingErrorOccurred += errorHandler; // Do not forget to remove these event handlers when they are not required any more. int id = IoTConnectivityClientManager.StartReceivingPresence(IoTConnectivityClientManager.MulticastAddress, "oic.iot.door");
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.ArgumentException | Thrown when there is an invalid parameter. |
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. |
See Also
API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
Precondition: Initialize() should be called to initialize.
Postcondition: When the resource receive presence, event handler will be invoked. You must destroy presence by calling StopReceivingPresence() if presence event is no longer needed.
Declaration
C#Copypublic static void StopReceivingPresence(int presenceId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | presenceId | The start presence request identifier. |
Remarks
Sends request to not to receive server's presence any more.
Examples
CopyEventHandler<PresenceReceivedEventArgs> handler = (sender, e) => { Console.Log("PresenceReceived, presence id :" + e.PresenceId); } EventHandler<FindingErrorOccurredEventArgs> errorHandler = (sender, e) => { Console.Log("Found error :" + e.Error.Message); } IoTConnectivityClientManager.PresenceReceived += handler; IoTConnectivityClientManager.FindingErrorOccurred += errorHandler; int id = IoTConnectivityClientManager.StartReceivingPresence(IoTConnectivityClientManager.MulticastAddress, "oic.iot.door"); await Task.Delay(5000); // Do other things here // Call StopReceivingPresence() when receiving presence is not required any more IoTConnectivityClientManager.PresenceReceived -= handler; IoTConnectivityClientManager.FindingErrorOccurred -= errorHandler; IoTConnectivityClientManager.StopReceivingPresence(id);
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
System.ArgumentException | Thrown when there is an invalid parameter. |
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. |
See Also
API Level: 3
Privilege Level: public
Privilege: http://tizen.org/privilege/internet
Feature: http://tizen.org/feature/iot.ocf
Precondition: Initialize() should be called to initialize.
Events
DeviceInformationFound
DeviceInformationFound event. This event occurs when device information is found after sending request using API StartFindingDeviceInformation().
Declaration
C#Copypublic static event EventHandler<DeviceInformationFoundEventArgs> DeviceInformationFound
Event Type
Type | Description |
---|---|
System.EventHandler<DeviceInformationFoundEventArgs> |
API Level: 3
Declaration
C#Copypublic static event EventHandler<FindingErrorOccurredEventArgs> FindingErrorOccurred
Event Type
Type | Description |
---|---|
System.EventHandler<FindingErrorOccurredEventArgs> |
API Level: 3
PlatformInformationFound
PlatformInformationFound event. This event occurs when platform information is found after sending request using API StartFindingPlatformInformation().
Declaration
C#Copypublic static event EventHandler<PlatformInformationFoundEventArgs> PlatformInformationFound
Event Type
Type | Description |
---|---|
System.EventHandler<PlatformInformationFoundEventArgs> |
API Level: 3
PresenceReceived
PresenceReceived event. This event occurs when server starts sending presence of a resource.
Declaration
C#Copypublic static event EventHandler<PresenceReceivedEventArgs> PresenceReceived
Event Type
Type | Description |
---|---|
System.EventHandler<PresenceReceivedEventArgs> |
API Level: 3
ResourceFound
ResourceFound event. This event occurs when a resource is found from the remote server after sending request using API StartFindingResource().
Declaration
C#Copypublic static event EventHandler<ResourceFoundEventArgs> ResourceFound
Event Type
Type | Description |
---|---|
System.EventHandler<ResourceFoundEventArgs> |