mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 18:41:56 +03:00
Tear down peer when signing out
This commit is contained in:
parent
a0daf47134
commit
9334267bd0
@ -84,7 +84,7 @@ pub fn init(client: Arc<Client>, cx: &mut MutableAppContext) {
|
|||||||
move |_: &SignOut, cx| {
|
move |_: &SignOut, cx| {
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
cx.spawn(|cx| async move {
|
cx.spawn(|cx| async move {
|
||||||
client.set_status(Status::SignedOut, &cx);
|
client.disconnect(&cx);
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
@ -1162,11 +1162,9 @@ impl Client {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disconnect(self: &Arc<Self>, cx: &AsyncAppContext) -> Result<()> {
|
pub fn disconnect(self: &Arc<Self>, cx: &AsyncAppContext) {
|
||||||
let conn_id = self.connection_id()?;
|
self.peer.teardown();
|
||||||
self.peer.disconnect(conn_id);
|
|
||||||
self.set_status(Status::SignedOut, cx);
|
self.set_status(Status::SignedOut, cx);
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connection_id(&self) -> Result<ConnectionId> {
|
fn connection_id(&self) -> Result<ConnectionId> {
|
||||||
|
@ -1083,7 +1083,7 @@ async fn test_calls_on_multiple_connections(
|
|||||||
assert!(incoming_call_b2.next().await.unwrap().is_none());
|
assert!(incoming_call_b2.next().await.unwrap().is_none());
|
||||||
|
|
||||||
// User B disconnects the client that is not on the call. Everything should be fine.
|
// User B disconnects the client that is not on the call. Everything should be fine.
|
||||||
client_b1.disconnect(&cx_b1.to_async()).unwrap();
|
client_b1.disconnect(&cx_b1.to_async());
|
||||||
deterministic.advance_clock(RECEIVE_TIMEOUT);
|
deterministic.advance_clock(RECEIVE_TIMEOUT);
|
||||||
client_b1
|
client_b1
|
||||||
.authenticate_and_connect(false, &cx_b1.to_async())
|
.authenticate_and_connect(false, &cx_b1.to_async())
|
||||||
@ -3227,7 +3227,7 @@ async fn test_leaving_project(
|
|||||||
buffer_b2.read_with(cx_b, |buffer, _| assert_eq!(buffer.text(), "a-contents"));
|
buffer_b2.read_with(cx_b, |buffer, _| assert_eq!(buffer.text(), "a-contents"));
|
||||||
|
|
||||||
// Drop client B's connection and ensure client A and client C observe client B leaving.
|
// Drop client B's connection and ensure client A and client C observe client B leaving.
|
||||||
client_b.disconnect(&cx_b.to_async()).unwrap();
|
client_b.disconnect(&cx_b.to_async());
|
||||||
deterministic.advance_clock(RECONNECT_TIMEOUT);
|
deterministic.advance_clock(RECONNECT_TIMEOUT);
|
||||||
project_a.read_with(cx_a, |project, _| {
|
project_a.read_with(cx_a, |project, _| {
|
||||||
assert_eq!(project.collaborators().len(), 1);
|
assert_eq!(project.collaborators().len(), 1);
|
||||||
@ -5772,7 +5772,7 @@ async fn test_contact_requests(
|
|||||||
.is_empty());
|
.is_empty());
|
||||||
|
|
||||||
async fn disconnect_and_reconnect(client: &TestClient, cx: &mut TestAppContext) {
|
async fn disconnect_and_reconnect(client: &TestClient, cx: &mut TestAppContext) {
|
||||||
client.disconnect(&cx.to_async()).unwrap();
|
client.disconnect(&cx.to_async());
|
||||||
client.clear_contacts(cx).await;
|
client.clear_contacts(cx).await;
|
||||||
client
|
client
|
||||||
.authenticate_and_connect(false, &cx.to_async())
|
.authenticate_and_connect(false, &cx.to_async())
|
||||||
@ -6186,7 +6186,7 @@ async fn test_following(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Following interrupts when client B disconnects.
|
// Following interrupts when client B disconnects.
|
||||||
client_b.disconnect(&cx_b.to_async()).unwrap();
|
client_b.disconnect(&cx_b.to_async());
|
||||||
deterministic.advance_clock(RECONNECT_TIMEOUT);
|
deterministic.advance_clock(RECONNECT_TIMEOUT);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
workspace_a.read_with(cx_a, |workspace, _| workspace.leader_for_pane(&pane_a)),
|
workspace_a.read_with(cx_a, |workspace, _| workspace.leader_for_pane(&pane_a)),
|
||||||
|
Loading…
Reference in New Issue
Block a user