feat: improved NOTICE messages for events and subscriptions

This commit is contained in:
Greg Heartsfield
2021-12-12 10:50:16 -06:00
parent 1589268eba
commit 531f6c4624
3 changed files with 29 additions and 12 deletions
+5 -5
View File
@@ -1,7 +1,9 @@
//! Client connection state
use crate::close::Close;
use crate::error::Error;
use crate::error::Result;
use crate::event::Event;
use crate::subscription::Subscription;
use log::*;
use std::collections::HashMap;
@@ -33,7 +35,7 @@ impl ClientConn {
ClientConn {
client_id,
subscriptions: HashMap::new(),
max_subs: 128,
max_subs: 32,
}
}
@@ -65,7 +67,7 @@ impl ClientConn {
"ignoring sub request with excessive length: ({})",
sub_id_len
);
return Ok(());
return Err(Error::SubIdMaxLengthError);
}
// check if an existing subscription exists, and replace if so
if self.subscriptions.contains_key(&k) {
@@ -77,9 +79,7 @@ impl ClientConn {
// check if there is room for another subscription.
if self.subscriptions.len() >= self.max_subs {
// TODO: return error/notice for this
info!("client has reached the maximum number of unique subscriptions");
return Ok(());
return Err(Error::SubMaxExceededError);
}
// add subscription
self.subscriptions.insert(k, s);