Command constructor

Command({
  1. required String cmd,
  2. String? requestId,
  3. int? timestamp,
  4. bool? requireAuth,
  5. int? errorCode,
  6. String? errorMessage,
  7. bool replyToChannel = false,
  8. Map<String, dynamic> payload = const {},
})

Implementation

Command({
  required this.cmd,
  this.requestId,
  this.timestamp,
  this.requireAuth,
  this.errorCode,
  this.errorMessage,
  this.replyToChannel = false,
  this.payload = const {},
}) {
  if (payload.isNotEmpty) {
    requestId ??= Uuid().v1();
    payload['req_id'] = requestId;
    replyToChannel = payload['reply_to_channel'] ?? replyToChannel;
    payload.removeWhere((key, value) => value == null);
  }
}