ClientMsg constructor
ClientMsg(
- String type, {
- String? id,
- Nip01Event? event,
- List<
Filter> ? filters,
Implementation
ClientMsg(
this.type, {
this.id,
this.event,
this.filters,
}) {
// verify based on type
if (type == ClientMsgType.kEvent) {
if (event == null) {
throw Exception("event is required for type EVENT");
}
}
if (type == ClientMsgType.kReq) {
if (filters == null) {
throw Exception("filters are required for type 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.kClose) {
if (id == null) {
throw Exception("id is required for type CLOSE");
}
}
if (type == ClientMsgType.kCount) {
throw Exception("COUNT is not implemented yet");
}
if (type == ClientMsgType.kAuth) {
if (event == null) {
throw Exception("event is required for type AUTH");
}
}
}