From 3c61a3e82650250bc8483872221b8d834d1d80b1 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 9 Sep 2021 15:40:35 +0200 Subject: [PATCH] Ensure client A and B can communicate after reconnection Co-Authored-By: Nathan Sobo --- server/src/rpc.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/server/src/rpc.rs b/server/src/rpc.rs index cc0d35d097a2bf860947ead3eb774e8eaf1b9c91..cd2409250eeff8bc9ace07442a2e813b851a5203 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -1831,6 +1831,44 @@ mod tests { }) .await; + // Ensure client A and B can communicate normally after reconnection. + channel_a + .update(&mut cx_a, |channel, cx| { + channel.send_message("you online?".to_string(), cx).unwrap() + }) + .await + .unwrap(); + channel_b + .condition(&cx_b, |channel, _| { + channel_messages(channel) + == [ + ("user_b".to_string(), "hello A, it's B.".to_string()), + ("user_a".to_string(), "oh, hi B.".to_string()), + ("user_a".to_string(), "sup".to_string()), + ("user_a".to_string(), "you online?".to_string()), + ] + }) + .await; + + channel_b + .update(&mut cx_b, |channel, cx| { + channel.send_message("yep".to_string(), cx).unwrap() + }) + .await + .unwrap(); + channel_a + .condition(&cx_a, |channel, _| { + channel_messages(channel) + == [ + ("user_b".to_string(), "hello A, it's B.".to_string()), + ("user_a".to_string(), "oh, hi B.".to_string()), + ("user_a".to_string(), "sup".to_string()), + ("user_a".to_string(), "you online?".to_string()), + ("user_b".to_string(), "yep".to_string()), + ] + }) + .await; + fn channel_messages(channel: &Channel) -> Vec<(String, String)> { channel .messages()