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
701a290a
Commit
701a290a
authored
Feb 18, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
尝试对接声网有关操作以及音视频+1.15
parent
1ebd2716
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
3 deletions
+26
-3
src/handles/handle_agora_call.rs
+0
-0
src/handles/handshake.rs
+14
-0
src/handles/redis.rs
+12
-3
No files found.
src/handles/handle_agora_call.rs
View file @
701a290a
This diff is collapsed.
Click to expand it.
src/handles/handshake.rs
View file @
701a290a
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashMap
;
use
dashmap
::
DashSet
;
use
lazy_static
::
lazy_static
;
use
tokio
::
net
::
TcpStream
;
use
tokio
::
net
::
TcpStream
;
use
tokio_tungstenite
::{
accept_hdr_async
,
WebSocketStream
};
use
tokio_tungstenite
::{
accept_hdr_async
,
WebSocketStream
};
use
tungstenite
::
handshake
::
client
::
Request
;
use
tungstenite
::
handshake
::
client
::
Request
;
use
tungstenite
::
handshake
::
server
::
Response
;
use
tungstenite
::
handshake
::
server
::
Response
;
// 存储可以为host的id集合
// 存储hasMike以及hasCamera
lazy_static!
{
pub
static
ref
HOST_ENABLED_ID_SET
:
DashSet
<
String
>
=
DashSet
::
new
();
}
// 提取出来的处理握手的函数
// 提取出来的处理握手的函数
pub
(
crate
)
fn
handle_handshake
(
pub
(
crate
)
fn
handle_handshake
(
req
:
&
tungstenite
::
handshake
::
server
::
Request
,
req
:
&
tungstenite
::
handshake
::
server
::
Request
,
...
@@ -38,6 +46,12 @@ pub(crate) fn handle_handshake(
...
@@ -38,6 +46,12 @@ pub(crate) fn handle_handshake(
return
Err
(
"wsPwd不正确!"
.to_string
());
return
Err
(
"wsPwd不正确!"
.to_string
());
}
}
// 存储是否为host
if
connection_params
.get
(
"enable_host"
)
.is_some
()
{
println!
(
"当前id允许可以成为host! {}"
,
connection_params
.get
(
"fromID"
)
.unwrap
());
HOST_ENABLED_ID_SET
.insert
(
connection_params
.get
(
"fromID"
)
.unwrap
()
.to_string
());
}
println!
(
"握手成功!"
);
println!
(
"握手成功!"
);
Ok
(
connection_params
)
Ok
(
connection_params
)
...
...
src/handles/redis.rs
View file @
701a290a
...
@@ -54,12 +54,21 @@ pub async fn insert_this_connection(
...
@@ -54,12 +54,21 @@ pub async fn insert_this_connection(
let
device_id
=
params
.get
(
"deviceID"
)
.cloned
()
.unwrap_or
(
""
.to_string
());
let
device_id
=
params
.get
(
"deviceID"
)
.cloned
()
.unwrap_or
(
""
.to_string
());
let
from_name
=
params
.get
(
"fromName"
)
.cloned
()
.unwrap_or
(
""
.to_string
());
let
from_name
=
params
.get
(
"fromName"
)
.cloned
()
.unwrap_or
(
""
.to_string
());
let
has_mike
=
if
let
Some
(
has_mike
)
=
params
.get
(
"hasMike"
){
has_mike
.to_string
()
}
else
{
"0"
.to_string
()
};
let
has_camera
=
if
let
Some
(
has_camera
)
=
params
.get
(
"hasCamera"
){
has_camera
.to_string
()
}
else
{
"0"
.to_string
()
};
// 按照结构体OnlineUserMessage的格式构造用户信息字符串,用逗号拼接即可
// 按照结构体OnlineUserMessage的格式构造用户信息字符串,用逗号拼接即可
// callState,channelID,deviceID,fromID,hasCamera,hasMike,isHost,userCallGroup,fromName
// callState,channelID,deviceID,fromID,hasCamera,hasMike,isHost,userCallGroup,fromName
let
user_info_str
=
format!
(
let
user_info_str
=
format!
(
"{},{},{},{},
1,1
,0,0,{}"
,
"{},{},{},{},
{},{}
,0,0,{}"
,
"idle"
,
""
,
from_id
,
device_id
,
from_name
"idle"
,
""
,
from_id
,
device_id
,
has_camera
,
has_mike
,
from_name
);
);
if
let
Err
(
e
)
=
con
.hset
::
<&
str
,
&
str
,
&
str
,
()
>
(
"onlineUsers"
,
from_id
,
&
user_info_str
)
{
if
let
Err
(
e
)
=
con
.hset
::
<&
str
,
&
str
,
&
str
,
()
>
(
"onlineUsers"
,
from_id
,
&
user_info_str
)
{
...
...
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