pub async fn trigger_session_end(
session_id: &str,
session_key: &str,
reason: Option<&str>,
) -> Result<InternalHookEvent>Expand description
触发 session:end 事件
当 Session 结束时调用此函数触发 session:end 事件。
事件的 context 包含 session_id、session_key 和可选的 reason 字段。
§参数
session_id: Session 的唯一标识符session_key: Session 的键(用于存储和检索)reason: 可选的结束原因(如 “clear”、“logout”、“exit”、“other”)
§返回值
返回触发后的 InternalHookEvent,调用者可以访问处理器添加的消息。
§示例
ⓘ
use aster::hooks::internal::trigger_session_end;
async fn end_session() {
let event = trigger_session_end(
"session-001",
"user:session:123",
Some("logout"),
).await.unwrap();
println!("Session ended, messages: {:?}", event.messages);
}Validates: Requirements 8.3, 8.5