VirtualDevice
public protocol VirtualDevice : AbstractVirtualDevice
VirtualDevice
for an enterprise-client adds methods to execute a write-only
or executable attribute.
-
Execute an action without an argument to the client
Throws
ClientError.argument
ifactionName
is not a valid action for this virtual device or ifactionName
requires and argument.deprecated
Declaration
Swift
func call(actionName: String) throws
Parameters
actionName
The name of the action
-
Execute an action with data to the target client
Throws
ClientError.argument
ifactionName
is not a valid action for this virtual device or ifargument
is not the correct type forname
.depreacated
Declaration
Swift
func call(actionName: String, argument: Any) throws
Parameters
actionName
The name of the action
argument
argument for the action
-
Set a callback that is invoked when any alert in the device model is received.
Note that it is possible to set a callback for a all alerts via
setOnAlert(callback:)
.Seealso
Declaration
Swift
func setOnAlert(formatURN: String, callback: @escaping (AlertEvent) -> ())
Parameters
formatURN
the format URN for the alert
callback
a callback to invoke when an alert is received
-
Set a callback that is invoked when any alert in the device model is received.
Note that it is possible to set a callback for a specific alert via
setOnAlert(formatURN:callback:)
.Seealso
Declaration
Swift
func setOnAlert(callback: @escaping (AlertEvent) -> ())
Parameters
callback
a callback for all alerts.
-
Set a callback that is invoked when custom data for the given format URN is received.
Note that it is possible to set a callback for a specific data format and to set a callback for all formats via
setOnData(callback:)
. If there is a callback for the specific data and for all formats, both callbacks will be invoked.Seealso
Declaration
Swift
func setOnData(formatURN: String, callback: @escaping (DataEvent) -> ())
Parameters
formatURN
The data format URN from the device model
callback
A callback to invoke when custom data is received with the format URN
-
Set a callback that is invoked when any custom data in the device model is received.
Note that it is possible to set a callback for a specific data format via
setOnData(formatURN:callback:)
.Seealso
Declaration
Swift
func setOnData(callback: @escaping (DataEvent) -> ())
Parameters
callback
a callback to invoke when custom data is received
-
Create an Action for this VirtualDevice. The action will be created for the named action in the device model.
- return: an Action
Throws
throws ClientError.argument: if there is no actionactionName
Declaration
Swift
func createAction(actionName: String) throws -> Action
Parameters
actionName
the name of the action.