Data
public protocol Data
Data is an object that represents a set of custom data fields (key/value
pairs) defined in the formats section of the device model. The custom data
is sent by calling the submit
method.
The set
method returns the Data
instance to allow
the data fields to be set in fluent style.
-
Set the value of a field in the
Data
. The fields are determined by the format given when the Data is created. The value is validated according to the constraints in the format. If the value is not valid, aClientError.argument
exception is thrown.All fields defined in the format that are not “optional” must be set before calling
submit()
Throws
ClientError.argument
iffield
isnil
orvalue
is not validDeclaration
Swift
func set(field: String, value: AnyObject) throws -> Data
Parameters
field
name of a field from the custom data format
value
the value to set
Return Value
Data
object that can be used for function chaining -
This method is used to actually send the custom data fields to the server. All mandatory fields (according to the device model definition) must be set before sending, otherwise an error will be thrown. Any error that can arise while sending will be handled by the
VirtualDevice.onError
handler, if set.After a successful send all the values are reset so to send again the values must be set again.
Throws
ClientError.argument
if a required field is not setClientError.network
if aMessageDispatcher
cannot be obtained.
Declaration
Swift
func submit() throws
-
Set a callback that is invoked if an error occurs when submitting the
Data
. The callback may benil
, which will un-set the callback.Declaration
Swift
func setOnError(callback: ((ErrorEvent) -> ())?)
Parameters
callback
a callback to invoke, or
nil