Include room_id
in CallCanceled
message
This ensures we don't accidentally cancel old calls.
This commit is contained in:
parent
e2b132ef23
commit
0220d7ba5d
4 changed files with 47 additions and 14 deletions
|
@ -94,12 +94,18 @@ impl ActiveCall {
|
||||||
|
|
||||||
async fn handle_call_canceled(
|
async fn handle_call_canceled(
|
||||||
this: ModelHandle<Self>,
|
this: ModelHandle<Self>,
|
||||||
_: TypedEnvelope<proto::CallCanceled>,
|
envelope: TypedEnvelope<proto::CallCanceled>,
|
||||||
_: Arc<Client>,
|
_: Arc<Client>,
|
||||||
mut cx: AsyncAppContext,
|
mut cx: AsyncAppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
this.update(&mut cx, |this, _| {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,13 @@ impl Server {
|
||||||
let pool = pool.lock().await;
|
let pool = pool.lock().await;
|
||||||
for canceled_user_id in canceled_calls_to_user_ids {
|
for canceled_user_id in canceled_calls_to_user_ids {
|
||||||
for connection_id in pool.user_connection_ids(canceled_user_id) {
|
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>,
|
response: Response<proto::JoinRoom>,
|
||||||
session: Session,
|
session: Session,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let room_id = RoomId::from_proto(request.id);
|
||||||
let room = {
|
let room = {
|
||||||
let room = session
|
let room = session
|
||||||
.db()
|
.db()
|
||||||
.await
|
.await
|
||||||
.join_room(
|
.join_room(room_id, session.user_id, session.connection_id)
|
||||||
RoomId::from_proto(request.id),
|
|
||||||
session.user_id,
|
|
||||||
session.connection_id,
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
room_updated(&room, &session.peer);
|
room_updated(&room, &session.peer);
|
||||||
room.clone()
|
room.clone()
|
||||||
|
@ -854,7 +857,12 @@ async fn join_room(
|
||||||
{
|
{
|
||||||
session
|
session
|
||||||
.peer
|
.peer
|
||||||
.send(connection_id, proto::CallCanceled {})
|
.send(
|
||||||
|
connection_id,
|
||||||
|
proto::CallCanceled {
|
||||||
|
room_id: room_id.to_proto(),
|
||||||
|
},
|
||||||
|
)
|
||||||
.trace_err();
|
.trace_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -978,7 +986,12 @@ async fn cancel_call(
|
||||||
{
|
{
|
||||||
session
|
session
|
||||||
.peer
|
.peer
|
||||||
.send(connection_id, proto::CallCanceled {})
|
.send(
|
||||||
|
connection_id,
|
||||||
|
proto::CallCanceled {
|
||||||
|
room_id: room_id.to_proto(),
|
||||||
|
},
|
||||||
|
)
|
||||||
.trace_err();
|
.trace_err();
|
||||||
}
|
}
|
||||||
response.send(proto::Ack {})?;
|
response.send(proto::Ack {})?;
|
||||||
|
@ -1005,7 +1018,12 @@ async fn decline_call(message: proto::DeclineCall, session: Session) -> Result<(
|
||||||
{
|
{
|
||||||
session
|
session
|
||||||
.peer
|
.peer
|
||||||
.send(connection_id, proto::CallCanceled {})
|
.send(
|
||||||
|
connection_id,
|
||||||
|
proto::CallCanceled {
|
||||||
|
room_id: room_id.to_proto(),
|
||||||
|
},
|
||||||
|
)
|
||||||
.trace_err();
|
.trace_err();
|
||||||
}
|
}
|
||||||
update_user_contacts(session.user_id, &session).await?;
|
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<()> {
|
async fn leave_room_for_session(session: &Session) -> Result<()> {
|
||||||
let mut contacts_to_update = HashSet::default();
|
let mut contacts_to_update = HashSet::default();
|
||||||
|
|
||||||
|
let room_id;
|
||||||
let canceled_calls_to_user_ids;
|
let canceled_calls_to_user_ids;
|
||||||
let live_kit_room;
|
let live_kit_room;
|
||||||
let delete_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_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);
|
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);
|
live_kit_room = mem::take(&mut left_room.room.live_kit_room);
|
||||||
delete_live_kit_room = left_room.room.participants.is_empty();
|
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) {
|
for connection_id in pool.user_connection_ids(canceled_user_id) {
|
||||||
session
|
session
|
||||||
.peer
|
.peer
|
||||||
.send(connection_id, proto::CallCanceled {})
|
.send(
|
||||||
|
connection_id,
|
||||||
|
proto::CallCanceled {
|
||||||
|
room_id: room_id.to_proto(),
|
||||||
|
},
|
||||||
|
)
|
||||||
.trace_err();
|
.trace_err();
|
||||||
}
|
}
|
||||||
contacts_to_update.insert(canceled_user_id);
|
contacts_to_update.insert(canceled_user_id);
|
||||||
|
|
|
@ -212,7 +212,9 @@ message IncomingCall {
|
||||||
optional ParticipantProject initial_project = 4;
|
optional ParticipantProject initial_project = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CallCanceled {}
|
message CallCanceled {
|
||||||
|
uint64 room_id = 1;
|
||||||
|
}
|
||||||
|
|
||||||
message CancelCall {
|
message CancelCall {
|
||||||
uint64 room_id = 1;
|
uint64 room_id = 1;
|
||||||
|
|
|
@ -6,4 +6,4 @@ pub use conn::Connection;
|
||||||
pub use peer::*;
|
pub use peer::*;
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
pub const PROTOCOL_VERSION: u32 = 40;
|
pub const PROTOCOL_VERSION: u32 = 41;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue