Show / Hide Table of Contents

    Class IoTConnectivityClientManager

    Definition

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

    IoT connectivity client manager consists of client side APIs.

    public static class IoTConnectivityClientManager
    Inheritance
    Object
    IoTConnectivityClientManager

    Fields

    View Source

    MulticastAddress

    The IP Address for multicast.

    Declaration
    public const string MulticastAddress = null
    Field Value
    Type Description
    String
    API Level: 3

    Properties

    View Source

    PollingInterval

    Polling interval of IoTConnectivity.

    Declaration
    public static int PollingInterval { get; set; }
    Property Value
    Type Description
    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
        IoTConnectivityClientManager.Initialize();
        IoTConnectivityClientManager.PollingInterval = 100;
    API Level: 3
    Precondition: Initialize() should be called to initialize.
    View Source

    TimeOut

    Timeout in seconds.

    Declaration
    public static int TimeOut { get; set; }
    Property Value
    Type Description
    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
        IoTConnectivityClientManager.Initialize();
        IoTConnectivityClientManager.TimeOut = 120;
    API Level: 3
    Precondition: Initialize() should be called to initialize.

    Methods

    View Source

    Deinitialize()

    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
    Initialize(String)
    API Level: 3
    Feature: http://tizen.org/feature/iot.ocf
    Precondition: Initialize() should be called to initialize.
    View Source

    Initialize(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
    NotSupportedException

    Thrown when the iotcon is not supported.

    ArgumentException

    Thrown when there is an invalid parameter.

    UnauthorizedAccessException

    Thrown when an application does not have privilege to access.

    See Also
    Deinitialize()
    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.
    View Source

    InvokePolling()

    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
    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.
    View Source

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

    See Also
    SetDeviceName(String)
    DeviceInformationFound
    DeviceInformationFoundEventArgs
    TimeOut
    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.
    View Source

    StartFindingPlatformInformation(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
    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
        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
    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.

    See Also
    PlatformInformationFound
    PlatformInformationFoundEventArgs
    TimeOut
    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.
    View Source

    StartFindingResource(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
    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
        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
    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.

    See Also
    ResourceFound
    ResourceFoundEventArgs
    TimeOut
    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.
    View Source

    StartReceivingPresence(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
    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
        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
    NotSupportedException

    Thrown when the iotcon is not supported.

    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
    StartSendingPresence(UInt32)
    StopSendingPresence()
    StopReceivingPresence(Int32)
    PresenceReceived
    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.
    View Source

    StopReceivingPresence(Int32)

    Stops receiving presence events.

    Declaration
    public static void StopReceivingPresence(int presenceId)
    Parameters
    Type Name Description
    Int32 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
    NotSupportedException

    Thrown when the iotcon is not supported.

    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
    StartSendingPresence(UInt32)
    StopSendingPresence()
    StartReceivingPresence(String, String)
    PresenceReceived
    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

    View Source

    DeviceInformationFound

    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
    EventHandler<DeviceInformationFoundEventArgs>
    API Level: 3
    View Source

    FindingErrorOccurred

    FindingError event. This event occurs when an error is found.

    Declaration
    public static event EventHandler<FindingErrorOccurredEventArgs> FindingErrorOccurred
    Event Type
    Type Description
    EventHandler<FindingErrorOccurredEventArgs>
    API Level: 3
    View Source

    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
    EventHandler<PlatformInformationFoundEventArgs>
    API Level: 3
    View Source

    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
    EventHandler<PresenceReceivedEventArgs>
    API Level: 3
    View Source

    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
    EventHandler<ResourceFoundEventArgs>
    API Level: 3
    • View Source
    Back to top Copyright © 2016-2020 Samsung
    Generated by DocFX