Classes
The following classes are available globally.
-
A directly-connected device is able to send messages to, and receive messages from, the IoT server. A directly-connected device has a physical-device identifier that is registered with the server. When the directly-connected device is activated on the server, the server assigns a logical-endpoint identifier. This logical-endpoint identifier is required for sending messages to, and receiving messages from, the server.
See moreDeclaration
Swift
public class DirectlyConnectedDevice : Client
-
A GatewayDevice is capable of registering indirectly–connected devices and proxies messages for indirectly-connected devices.
See moreDeclaration
Swift
public class GatewayDevice : DirectlyConnectedDevice
-
ExternalObject represents the value of a URI type in a data model. The application is responsible for uploading/downloading the content referred to by the URI.
See moreDeclaration
Swift
public class ExternalObject : Hashable
-
A callback interface for receiving an event when content referred to by an attribute value has been successfully synchronized, or has failed to be synchronized. See
See moresetOnSync
Declaration
Swift
open class SyncCallback
-
StorageObject provides information about content in cloud storage.
See more// Upload example var lenna:StorageObject = directlyConnectedDevice.createStorageObject(name:"lenna.jpg", contentType: "image/jpeg") lenna.setInputPath(inputPath:"images/lenna.jpg") // onSync is called when the content referenced by the storageObject // is in sync with the storage cloud, or the sync has failed. lenna.setOnSync(callback: { event in let storageObject:StorageObject = event.getSource() if storageObject.getSyncStatus() == SyncStatus.inSync { // image was uploaded and can be deleted } else if storageObject.getSyncStatus() == SyncStatus.syncFailed { // image was not uploaded, take action! } }) virtualDevice.set(attributeName:"image", attributeValue:lenna) // Download example // onChange is called when the attribute value changes. virtualDevice.setOnChange(attributeName:"image", callback: { event in var namedValue:NamedValue = event.getNamedValue() var storageObject:StorageObject = namedValue.getValue() as StorageObject if storageObject.getContentLength() < availableDiskSpace { // syncTo will kick off the async download of the content storageObject.setOnSync(callback: { event in let storageObject:StorageObject = event.getSource() if storageObject.getSyncStatus() == SyncStatus.inSync { // image was downloaded and can now be used } else if storageObject.getSyncStatus() == SyncStatus.syncFailed { // image was not downloaded, take action! } } storageObject.setOutputPath(outputPath:"downloads" + storageObject.getName()) storageObject.sync() } }) }
Declaration
Swift
public class StorageObject : ExternalObject