Commit 717921fb by qlintonger xeno

阐释添加额外消息发送+1

parent 7fbb3b4f
......@@ -16,6 +16,11 @@ lazy_static! {
// 从 Redis 的 onlineUsers 集合中移除当前用户的信息
pub async fn remove_this_connection(from_id: &str) -> Result<(), redis::RedisError> {
{
ONLINE_USERS.remove(from_id);
println!("成功从全局变量中移除用户id: {} 的信息", from_id);
}
let mut con = REDIS_POOL
.get_connection()
.expect("Failed to get Redis connection");
......@@ -24,11 +29,6 @@ pub async fn remove_this_connection(from_id: &str) -> Result<(), redis::RedisErr
println!("从 Redis 中的 onlineUsers 哈希表删除用户信息时出错: {}", e);
return Err(e);
}
{
ONLINE_USERS.remove(from_id);
println!("成功从全局变量中移除用户id: {} 的信息", from_id);
}
Ok(())
}
......@@ -52,9 +52,6 @@ pub async fn insert_this_connection(
from_id: &str,
params: &HashMap<String, String>,
) -> Result<(), redis::RedisError> {
let mut con = REDIS_POOL
.get_connection()
.expect("Failed to get Redis connection");
let device_id = params.get("deviceID").cloned().unwrap_or("".to_string());
let from_name = params.get("fromName").cloned().unwrap_or("".to_string());
......@@ -84,6 +81,10 @@ pub async fn insert_this_connection(
"idle", "", device_id, from_id, has_camera, has_mike, user_call_group, from_name_decoded
);
let mut con = REDIS_POOL
.get_connection()
.expect("Failed to get Redis connection");
if let Err(e) = con.hset::<&str, &str, &str, ()>("onlineUsers", from_id, &user_info_str) {
println!(
"将用户信息添加到 Redis 中的 onlineUsers 哈希表时出错: {}",
......
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