-
Notifications
You must be signed in to change notification settings - Fork 39
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
Make max_ccu based on users, not sessions #74
Conversation
return Err(From::from("Room is full.")); | ||
} | ||
if switchboard.sessions().len() > config.max_ccu { | ||
if switchboard.get_all_users().count() >= config.max_ccu { |
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.
Yes, I saw in my tests this was off by one here, and forgot to report. 👍
|
||
// hack -- use data channel subscription to infer this, it would probably be nicer if | ||
// connections announced explicitly whether they were a publisher or subscriber | ||
let gets_data_channel = subscribe.as_ref().map(|s| s.data).unwrap_or(false); | ||
let join_kind = if gets_data_channel { JoinKind::Publisher } else { JoinKind::Subscriber }; | ||
|
||
if join_kind == JoinKind::Publisher { | ||
if switchboard.publishers_occupying(&room_id).len() > config.max_room_size { | ||
if room_users.len() > config.max_room_size { |
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.
Previously we iterated twice over the publishers_by_room
HashMap because get_users
called publishers_occupying
too. So this is nice we are only doing it once now.
result | ||
pub fn get_room_users(&self, room: &RoomId) -> impl Iterator<Item = &UserId> { | ||
self.publishers_occupying(room).iter().filter_map(|s| { | ||
s.join_state.get().map(|j| &j.user_id) |
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.
I was going to say what the behavior here when s.join_state.get()
return null (create_session and setup_media have been called but not yet process_join), but publishers_occupying
is using the publishers_by_room
HashMap and we know that join_state
is set at this time. So all good.
The max_ccu works now as documented in the config file, this is great. A note, I see in the code there is |
Fixes #57. (It was also off by one.)