diff --git a/src/cursor/controller.rs b/src/cursor/controller.rs index a311150..a959b1a 100644 --- a/src/cursor/controller.rs +++ b/src/cursor/controller.rs @@ -4,7 +4,6 @@ use tokio::sync::{mpsc, broadcast::{self, error::{TryRecvError, RecvError}}, Mutex, watch}; use tonic::async_trait; -use uuid::Uuid; use crate::{api::Controller, errors::IgnorableError, proto::cursor::{CursorEvent, CursorPosition}}; @@ -21,7 +20,6 @@ use crate::{api::Controller, errors::IgnorableError, proto::cursor::{CursorEvent /// upon dropping this handle will stop the associated worker #[derive(Debug)] pub struct CursorController { - user_id: Uuid, op: mpsc::UnboundedSender, last_op: Mutex>, stream: Mutex>, @@ -36,13 +34,12 @@ impl Drop for CursorController { impl CursorController { pub(crate) fn new( - user_id: Uuid, op: mpsc::UnboundedSender, last_op: Mutex>, stream: Mutex>, stop: mpsc::UnboundedSender<()>, ) -> Self { - CursorController { user_id, op, last_op, stream, stop } + CursorController { op, last_op, stream, stop } } } diff --git a/src/cursor/worker.rs b/src/cursor/worker.rs index f4c0072..3f45dfc 100644 --- a/src/cursor/worker.rs +++ b/src/cursor/worker.rs @@ -2,14 +2,12 @@ use std::sync::Arc; use tokio::sync::{mpsc, broadcast::{self}, Mutex, watch}; use tonic::{Streaming, async_trait}; -use uuid::Uuid; use crate::{api::controller::ControllerWorker, errors::IgnorableError, proto::cursor::{CursorPosition, CursorEvent}}; use super::controller::CursorController; pub(crate) struct CursorWorker { - user_id: Uuid, producer: mpsc::UnboundedSender, op: mpsc::UnboundedReceiver, changed: watch::Sender, @@ -19,14 +17,13 @@ pub(crate) struct CursorWorker { stop_control: mpsc::UnboundedSender<()>, } -impl CursorWorker { - pub(crate) fn new(user_id: Uuid) -> Self { +impl Default for CursorWorker { + fn default() -> Self { let (op_tx, op_rx) = mpsc::unbounded_channel(); let (cur_tx, _cur_rx) = broadcast::channel(64); let (end_tx, end_rx) = mpsc::unbounded_channel(); let (change_tx, change_rx) = watch::channel(CursorEvent::default()); Self { - user_id, producer: op_tx, op: op_rx, changed: change_tx, @@ -46,7 +43,6 @@ impl ControllerWorker for CursorWorker { fn subscribe(&self) -> CursorController { CursorController::new( - self.user_id.clone(), self.producer.clone(), Mutex::new(self.last_op.clone()), Mutex::new(self.channel.subscribe()), @@ -58,7 +54,6 @@ impl ControllerWorker for CursorWorker { loop { tokio::select!{ Ok(Some(cur)) = rx.message() => { - if Uuid::from(cur.user.clone()) == self.user_id { continue } self.channel.send(cur.clone()).unwrap_or_warn("could not broadcast event"); self.changed.send(cur).unwrap_or_warn("could not update last event"); }, diff --git a/src/prelude.rs b/src/prelude.rs index 3a2934b..077a94b 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -31,4 +31,4 @@ pub use crate::{ proto::cursor::CursorPosition as CodempCursorPosition, proto::cursor::CursorEvent as CodempCursorEvent, proto::cursor::RowCol as CodempRowCol, -}; \ No newline at end of file +};