add constructor for typing service

This commit is contained in:
Charles Hall 2024-10-08 16:08:51 -07:00
parent b18df8de70
commit 3b28d0cfda
No known key found for this signature in database
GPG key ID: 7B8E0645816E07CF
2 changed files with 13 additions and 10 deletions

View file

@ -11,14 +11,21 @@ use crate::{services, utils, Result};
pub(crate) struct Service {
// u64 is unix timestamp of timeout
pub(crate) typing:
RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>,
typing: RwLock<BTreeMap<OwnedRoomId, BTreeMap<OwnedUserId, u64>>>,
// timestamp of the last change to typing users
pub(crate) last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>,
pub(crate) typing_update_sender: broadcast::Sender<OwnedRoomId>,
last_typing_update: RwLock<BTreeMap<OwnedRoomId, u64>>,
typing_update_sender: broadcast::Sender<OwnedRoomId>,
}
impl Service {
pub(crate) fn new() -> Self {
Self {
typing: RwLock::new(BTreeMap::new()),
last_typing_update: RwLock::new(BTreeMap::new()),
typing_update_sender: broadcast::channel(100).0,
}
}
/// Sets a user as typing until the timeout timestamp is reached or
/// `roomtyping_remove` is called.
#[tracing::instrument(skip(self))]