Commit 60102efc authored by xuwencheng's avatar xuwencheng

store

parent d932d0e0
......@@ -10,6 +10,7 @@ pub enum EventType {
PublishEvent = 10,
// 连接事件
ConnectEvent = 20,
CleanSessionEvent = 23,
}
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
......
......@@ -118,11 +118,13 @@ impl PublishEvent for SocketEvent {
pub trait ConnectEvent {
fn connect(
token_info: &TokenInfo,
info: &TokenInfo,
status: Status,
desc: impl AsRef<str>,
extra: Option<impl AsRef<str>>,
) -> SocketEvent;
fn clean_session(info: &TokenInfo, extra: impl AsRef<str>) -> SocketEvent;
}
impl ConnectEvent for SocketEvent {
......@@ -150,4 +152,24 @@ impl ConnectEvent for SocketEvent {
extra: extra.map(|s| s.as_ref().to_string()),
}
}
fn clean_session(info: &TokenInfo, extra: impl AsRef<str>) -> SocketEvent {
SocketEvent {
seller_id: Some(info.seller_id),
store_id: Some(info.seller_id),
device_id: Some(info.device_id.clone()),
client_type: Some(info.client_type),
version: Some(info.version),
version_desc: info.version_desc.clone(),
event: "连接事件".to_string(),
event_ty: EventType::CleanSessionEvent as i32,
key: None,
qos: None,
msg_id: None,
msg_ty: None,
status: Status::Fail as i32,
desc: "清理历史消息".to_string(),
extra: Some(extra.as_ref().to_string()),
}
}
}
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