ClientMsg constructor

ClientMsg(
  1. String type, {
  2. String? id,
  3. required List<Filter> filters,
})

Implementation

ClientMsg(
  this.type, {
  this.id,
  required this.filters,
}) {
  // verify based on type
  if (type == ClientMsgType.EVENT) {
    if (event == null) {
      throw Exception("event is required for type EVENT");
    }
  }

  if (type == ClientMsgType.REQ) {
    if (filters.isEmpty) {
      throw Exception("filters are required for type REQ");
    }
    if (id == null) {
      throw Exception("id is required for type REQ");
    }
  }

  if (type == ClientMsgType.CLOSE) {
    if (id == null) {
      throw Exception("id is required for type CLOSE");
    }
  }
  if (type == ClientMsgType.COUNT) {
    throw Exception("COUNT is not implemented yet");
  }
}