Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Include `room_id` in `CallCanceled` message
Antonio Scandurra0220d7ba5de3
diff --git a/crates/call/src/call.rs b/crates/call/src/call.rsindex 803fbb906ad..c63b2e0f5bb 100644--- a/crates/call/src/call.rs+++ b/crates/call/src/call.rs@@ -94,12 +94,18 @@ impl ActiveCall {async fn handle_call_canceled(this: ModelHandle<Self>,- _: TypedEnvelope<proto::CallCanceled>,+ envelope: TypedEnvelope<proto::CallCanceled>,_: Arc<Client>,mut cx: AsyncAppContext,) -> Result<()> {this.update(&mut cx, |this, _| {- *this.incoming_call.0.borrow_mut() = None;+ let mut incoming_call = this.incoming_call.0.borrow_mut();+ if incoming_call+ .as_ref()+ .map_or(false, |call| call.room_id == envelope.payload.room_id)+ {+ incoming_call.take();+ }});Ok(())}diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rsindex 5b0023fa99d..2c1733aeb3e 100644--- a/crates/collab/src/rpc.rs+++ b/crates/collab/src/rpc.rs@@ -271,7 +271,13 @@ impl Server {let pool = pool.lock().await;for canceled_user_id in canceled_calls_to_user_ids {for connection_id in pool.user_connection_ids(canceled_user_id) {- peer.send(connection_id, proto::CallCanceled {}).trace_err();+ peer.send(+ connection_id,+ proto::CallCanceled {+ room_id: room_id.to_proto(),+ },+ )+ .trace_err();}}}@@ -833,15 +839,12 @@ async fn join_room(response: Response<proto::JoinRoom>,session: Session,) -> Result<()> {+ let room_id = RoomId::from_proto(request.id);let room = {let room = session.db().await- .join_room(- RoomId::from_proto(request.id),- session.user_id,- session.connection_id,- )+ .join_room(room_id, session.user_id, session.connection_id).await?;room_updated(&room, &session.peer);room.clone()@@ -854,7 +857,12 @@ async fn join_room({session.peer- .send(connection_id, proto::CallCanceled {})+ .send(+ connection_id,+ proto::CallCanceled {+ room_id: room_id.to_proto(),+ },+ ).trace_err();}@@ -978,7 +986,12 @@ async fn cancel_call({session.peer- .send(connection_id, proto::CallCanceled {})+ .send(+ connection_id,+ proto::CallCanceled {+ room_id: room_id.to_proto(),+ },+ ).trace_err();}response.send(proto::Ack {})?;@@ -1005,7 +1018,12 @@ async fn decline_call(message: proto::DeclineCall, session: Session) -> Result<({session.peer- .send(connection_id, proto::CallCanceled {})+ .send(+ connection_id,+ proto::CallCanceled {+ room_id: room_id.to_proto(),+ },+ ).trace_err();}update_user_contacts(session.user_id, &session).await?;@@ -1922,6 +1940,7 @@ async fn update_user_contacts(user_id: UserId, session: &Session) -> Result<()>async fn leave_room_for_session(session: &Session) -> Result<()> {let mut contacts_to_update = HashSet::default();+ let room_id;let canceled_calls_to_user_ids;let live_kit_room;let delete_live_kit_room;@@ -1934,6 +1953,7 @@ async fn leave_room_for_session(session: &Session) -> Result<()> {}room_updated(&left_room.room, &session.peer);+ room_id = RoomId::from_proto(left_room.room.id);canceled_calls_to_user_ids = mem::take(&mut left_room.canceled_calls_to_user_ids);live_kit_room = mem::take(&mut left_room.room.live_kit_room);delete_live_kit_room = left_room.room.participants.is_empty();@@ -1945,7 +1965,12 @@ async fn leave_room_for_session(session: &Session) -> Result<()> {for connection_id in pool.user_connection_ids(canceled_user_id) {session.peer- .send(connection_id, proto::CallCanceled {})+ .send(+ connection_id,+ proto::CallCanceled {+ room_id: room_id.to_proto(),+ },+ ).trace_err();}contacts_to_update.insert(canceled_user_id);diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.protoindex f7c7bfd6bcc..cf58adfe0b0 100644--- a/crates/rpc/proto/zed.proto+++ b/crates/rpc/proto/zed.proto@@ -212,7 +212,9 @@ message IncomingCall {optional ParticipantProject initial_project = 4;}-message CallCanceled {}+message CallCanceled {+ uint64 room_id = 1;+}message CancelCall {uint64 room_id = 1;diff --git a/crates/rpc/src/rpc.rs b/crates/rpc/src/rpc.rsindex 5ca5711d9ca..1d4a4496d0a 100644--- a/crates/rpc/src/rpc.rs+++ b/crates/rpc/src/rpc.rs@@ -6,4 +6,4 @@ pub use conn::Connection;pub use peer::*;mod macros;-pub const PROTOCOL_VERSION: u32 = 40;+pub const PROTOCOL_VERSION: u32 = 41;