DeviceCommand class
A command class intended to be extended to provide comamnds and controls events between the backend server, the device drivers, and the devices themselves.
Applications register their own commands through the registerCustomCommands function.
Constructors
- DeviceCommand.new({String? id, required dynamic payload, DateTime? timestamp, required String type})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
The unique id of the command. Used to identify replies associated with
the command.
final
- payload → dynamic
-
The payload of the command. Each command must define the structure of
the payload.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- timestamp → DateTime
-
The timestamp the command was created.
final
- type → String
-
The type of the command. This is used by the system to deserialize the
command from JSON into the proper model.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Encodes this command into a JSON compatible map.
-
toString(
) → String - Returns the string encoded JSON representation for this class. This will remove all null values and empty collections from the returned string.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromDynamic(
dynamic map) → DeviceCommand -
Deserializes the command from a Map or a map-like object into the the
proper data model. This will throw an exception if
map
is null. -
registerCustomCommands(
Map< String, DeviceCommand Function(dynamic, String, DateTime)> builders) → void - Allows an application to register it's own custom commands. This is additive so it may be called multiple times to add multiple sets of custom commands.