Class IoTConnectivityClientManager
Definition
- Namespace:
- Tizen.Network.IoTConnectivity
- Assembly:
- Tizen.Network.IoTConnectivity.dll
IoT connectivity client manager consists of client side APIs.
public static class IoTConnectivityClientManager
- Inheritance
-
objectIoTConnectivityClientManager
Fields
View SourceMulticastAddress
The IP Address for multicast.
Declaration
public const string MulticastAddress = null
Field Value
Type | Description |
---|---|
string |
Properties
View SourcePollingInterval
Polling interval of IoTConnectivity.
Declaration
public static int PollingInterval { get; set; }
Property Value
Type | Description |
---|---|
int | 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
IoTConnectivityClientManager.Initialize();
IoTConnectivityClientManager.PollingInterval = 100;
View Source
TimeOut
Timeout in seconds.
Declaration
public static int TimeOut { get; set; }
Property Value
Type | Description |
---|---|
int | 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
IoTConnectivityClientManager.Initialize();
IoTConnectivityClientManager.TimeOut = 120;
Methods
View SourceDeinitialize()
Deinitializes IoTCon.
Declaration
public static void Deinitialize()
Remarks
This API must be called if IoTCon API is no longer needed.
Examples
IoTConnectivityClientManager.Deinitialize();
See Also
View SourceInitialize(string)
Initializes IoTCon. Call this function to start IoTCon.
Declaration
public static void Initialize(string filePath)
Parameters
Type | Name | Description |
---|---|---|
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
string 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. |
System.UnauthorizedAccessException | Thrown when an application does not have privilege to access. |
See Also
View SourceInvokePolling()
Invokes a next message from a queue for receiving messages from others, immediately.
Declaration
public 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
IoTConnectivityClientManager.InvokePolling();
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown when the iotcon is not supported. |
StartFindingDeviceInformation(string, ResourceQuery)
Starts finding the device information of remote server.
Declaration
public static int StartFindingDeviceInformation(string hostAddress, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
string | hostAddress | The host address of the remote server. |
ResourceQuery | query | The query specified as a filter for founding resources. |
Returns
Type | Description |
---|---|
int | 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
EventHandler<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. |
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. |
See Also
View SourceStartFindingPlatformInformation(string, ResourceQuery)
Starts finding the platform information of remote server.
Declaration
public static int StartFindingPlatformInformation(string hostAddress, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
string | hostAddress | The host address of remote server. |
ResourceQuery | query | The query specified as a filter for founding resources. |
Returns
Type | Description |
---|---|
int | 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
EventHandler<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. |
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. |
See Also
View SourceStartFindingResource(string, ResourceQuery)
Starts finding resources.
Declaration
public static int StartFindingResource(string hostAddress, ResourceQuery query = null)
Parameters
Type | Name | Description |
---|---|---|
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 |
---|---|
int | 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
EventHandler<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. |
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. |
See Also
View SourceStartReceivingPresence(string, string)
Starts receiving presence events.
Declaration
public static int StartReceivingPresence(string hostAddress, string resourceType)
Parameters
Type | Name | Description |
---|---|---|
string | hostAddress | The address or addressable name of the server. |
string | resourceType | A resource type that a client is interested in. |
Returns
Type | Description |
---|---|
int | 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
EventHandler<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. |
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. |
See Also
View SourceStopReceivingPresence(int)
Stops receiving presence events.
Declaration
public static void StopReceivingPresence(int presenceId)
Parameters
Type | Name | Description |
---|---|---|
int | presenceId | The start presence request identifier. |
Remarks
Sends request to not to receive server's presence any more.
Examples
EventHandler<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. |
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. |
See Also
Events
View SourceDeviceInformationFound
DeviceInformationFound event. This event occurs when device information is found after sending request using API StartFindingDeviceInformation().
Declaration
public static event EventHandler<DeviceInformationFoundEventArgs> DeviceInformationFound
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><DeviceInformationFoundEventArgs> |
FindingErrorOccurred
FindingError event. This event occurs when an error is found.
Declaration
public static event EventHandler<FindingErrorOccurredEventArgs> FindingErrorOccurred
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><FindingErrorOccurredEventArgs> |
PlatformInformationFound
PlatformInformationFound event. This event occurs when platform information is found after sending request using API StartFindingPlatformInformation().
Declaration
public static event EventHandler<PlatformInformationFoundEventArgs> PlatformInformationFound
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><PlatformInformationFoundEventArgs> |
PresenceReceived
PresenceReceived event. This event occurs when server starts sending presence of a resource.
Declaration
public static event EventHandler<PresenceReceivedEventArgs> PresenceReceived
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><PresenceReceivedEventArgs> |
ResourceFound
ResourceFound event. This event occurs when a resource is found from the remote server after sending request using API StartFindingResource().
Declaration
public static event EventHandler<ResourceFoundEventArgs> ResourceFound
Event Type
Type | Description |
---|---|
System.EventHandler<TEventArgs><ResourceFoundEventArgs> |