Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
ws-rst
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qlintonger xeno
ws-rst
Commits
a8e1f401
Commit
a8e1f401
authored
Feb 19, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cancel-call和call成功,但是出现死锁问题,卡顿在step - 0这里
parent
19bee953
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
src/client.rs
+28
-12
src/handles/handle_agora_call.rs
+0
-0
No files found.
src/client.rs
View file @
a8e1f401
...
...
@@ -28,14 +28,20 @@ pub(crate) async fn handle_client(
let
must_existed_params
=
[
"deviceID"
,
"fromID"
,
"wsPwd"
];
let
mut
connection_params
=
None
;
let
ws_stream
=
match
handle_websocket_handshake
(
stream
,
&
must_existed_params
,
STATIC_WS_PWD
,
&
mut
connection_params
)
.await
{
Ok
(
ws
)
=>
ws
,
Err
(
e
)
=>
{
println!
(
"WebSocket握手失败: {:?}"
,
e
);
return
Ok
(());
}
};
let
ws_stream
=
match
handle_websocket_handshake
(
stream
,
&
must_existed_params
,
STATIC_WS_PWD
,
&
mut
connection_params
,
)
.await
{
Ok
(
ws
)
=>
ws
,
Err
(
e
)
=>
{
println!
(
"WebSocket握手失败: {:?}"
,
e
);
return
Ok
(());
}
};
let
(
mut
sender
,
mut
receiver
)
=
ws_stream
.split
();
let
mut
last_heartbeat_time
=
Instant
::
now
();
// 包装为 Arc<Mutex<Instant>>
...
...
@@ -83,7 +89,11 @@ pub(crate) async fn handle_client(
}
ClientMessage
::
SendClientMessage
(
from_id
,
client_message
,
close
)
=>
{
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
{
println!
(
"发送给用户id {} 独立消息失败:{:?}"
,
real_user_id
,
e
);
break
;
...
...
@@ -135,6 +145,8 @@ pub(crate) async fn handle_client(
}
}
}
else
{
// 断开连接之后直接移除即可
event_sender
.send
(
Event
::
CloseConnection
((
from_id
.clone
(),
connection_time
)))
.unwrap
();
break
;
// 客户端断开连接
}
}
...
...
@@ -156,9 +168,13 @@ pub(crate) async fn handle_client(
}
// 发送关闭连接事件
event_sender
.send
(
Event
::
CloseConnection
((
from_id
.clone
(),
connection_time
)))
.unwrap
();
if
let
Err
(
e
)
=
event_sender
.send
(
Event
::
CloseConnection
((
from_id
.clone
(),
connection_time
)))
{
println!
(
"发送关闭消息到事件中心失败! 原因: {:?}"
,
e
);
}
else
{
println!
(
"发送关闭消息到事件中心成功!"
);
}
// 等待事件中心调度任务结束
if
let
Err
(
e
)
=
event_task
.await
{
...
...
src/handles/handle_agora_call.rs
View file @
a8e1f401
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment