Commit a8e1f401 by qlintonger xeno

cancel-call和call成功,但是出现死锁问题,卡顿在step - 0这里

parent 19bee953
...@@ -28,8 +28,14 @@ pub(crate) async fn handle_client( ...@@ -28,8 +28,14 @@ pub(crate) async fn handle_client(
let must_existed_params = ["deviceID", "fromID", "wsPwd"]; let must_existed_params = ["deviceID", "fromID", "wsPwd"];
let mut connection_params = None; let mut connection_params = None;
let ws_stream = let ws_stream = match handle_websocket_handshake(
match handle_websocket_handshake(stream, &must_existed_params, STATIC_WS_PWD, &mut connection_params).await { stream,
&must_existed_params,
STATIC_WS_PWD,
&mut connection_params,
)
.await
{
Ok(ws) => ws, Ok(ws) => ws,
Err(e) => { Err(e) => {
println!("WebSocket握手失败: {:?}", e); println!("WebSocket握手失败: {:?}", e);
...@@ -83,7 +89,11 @@ pub(crate) async fn handle_client( ...@@ -83,7 +89,11 @@ pub(crate) async fn handle_client(
} }
ClientMessage::SendClientMessage(from_id, client_message, close) => { ClientMessage::SendClientMessage(from_id, client_message, close) => {
let real_user_id = from_id.0; let real_user_id = from_id.0;
println!("消息中心:==> 收到消息 {:?} 发送给 {}", &client_message, real_user_id.clone()); println!(
"消息中心:==> 收到消息 {:?} 发送给 {}",
&client_message,
real_user_id.clone()
);
if let Err(e) = sender.send(Message::text(client_message)).await { if let Err(e) = sender.send(Message::text(client_message)).await {
println!("发送给用户id {} 独立消息失败:{:?}", real_user_id, e); println!("发送给用户id {} 独立消息失败:{:?}", real_user_id, e);
break; break;
...@@ -135,6 +145,8 @@ pub(crate) async fn handle_client( ...@@ -135,6 +145,8 @@ pub(crate) async fn handle_client(
} }
} }
} else { } else {
// 断开连接之后直接移除即可
event_sender.send(Event::CloseConnection((from_id.clone(), connection_time))).unwrap();
break; // 客户端断开连接 break; // 客户端断开连接
} }
} }
...@@ -156,9 +168,13 @@ pub(crate) async fn handle_client( ...@@ -156,9 +168,13 @@ pub(crate) async fn handle_client(
} }
// 发送关闭连接事件 // 发送关闭连接事件
event_sender if let Err(e) =
.send(Event::CloseConnection((from_id.clone(), connection_time))) event_sender.send(Event::CloseConnection((from_id.clone(), connection_time)))
.unwrap(); {
println!("发送关闭消息到事件中心失败! 原因: {:?}", e);
} else {
println!("发送关闭消息到事件中心成功!");
}
// 等待事件中心调度任务结束 // 等待事件中心调度任务结束
if let Err(e) = event_task.await { if let Err(e) = event_task.await {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment