Skip to content

Commit d0e3340

Browse files
committed
nostr: add NEG-CLOSE client message
1 parent aa4184e commit d0e3340

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

crates/nostr/src/message/client.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ pub enum ClientMessage {
6262
/// Message
6363
message: String,
6464
},
65+
/// Negentropy Close
66+
NegClose {
67+
/// Subscription ID
68+
subscription_id: SubscriptionId,
69+
},
6570
}
6671

6772
impl Serialize for ClientMessage {
@@ -186,6 +191,7 @@ impl ClientMessage {
186191
subscription_id,
187192
message,
188193
} => json!(["NEG-MSG", subscription_id, message]),
194+
Self::NegClose { subscription_id } => json!(["NEG-CLOSE", subscription_id]),
189195
}
190196
}
191197

@@ -313,6 +319,16 @@ impl ClientMessage {
313319
});
314320
}
315321

322+
// Negentropy Close
323+
// ["NEG-CLOSE", <subscription ID string>]
324+
if v[0] == "NEG-CLOSE" {
325+
if v_len != 2 {
326+
return Err(MessageHandleError::InvalidMessageFormat);
327+
}
328+
let subscription_id: SubscriptionId = SubscriptionId::new(v[1].to_string());
329+
return Ok(Self::NegClose { subscription_id });
330+
}
331+
316332
Err(MessageHandleError::InvalidMessageFormat)
317333
}
318334

0 commit comments

Comments
 (0)