-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added broadcast_message_scoped to allow sending messages only to users with a specific entity in their scope #167
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,18 @@ impl<E: Copy + Eq + Hash> EntityScopeMap<E> { | |
} | ||
} | ||
|
||
pub fn get(&self, user_key: &UserKey, entity: &E) -> Option<&bool> { | ||
pub fn get(&self, user_key: &UserKey, entity: &E) -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated this function to return a bool instead of an option of a borrowed bool. |
||
let key = (*user_key, *entity); | ||
|
||
self.main_map.get(&key) | ||
self.main_map.get(&key).map(|k| *k).unwrap_or(false) | ||
} | ||
|
||
pub fn insert(&mut self, user_key: UserKey, entity: E, in_scope: bool) { | ||
if self.main_map.contains_key(&(user_key, entity)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in this check to see if the scope is just being updated rather than inserted. |
||
// Only need to update scope status | ||
self.main_map.insert((user_key, entity), in_scope); | ||
return; | ||
} | ||
self.entities_of_user | ||
.entry(user_key) | ||
.or_insert_with(|| HashSet::new()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to take advantage of get returning just a bool instead of an option of a borrowed bool