Commit 7b11a1d3 authored by xuwencheng's avatar xuwencheng

store

parent c46e749c
......@@ -18,17 +18,22 @@ pub struct SocketEvent {
pub event: String,
// 事件类型
pub event_ty: i32,
// 事件状态
pub status: i32,
// 事件描述
pub desc: String,
// 消息信息
// 关键字
pub key: Option<String>,
// 消息id
pub msg_id: Option<i64>,
// 消息类型
pub msg_ty: Option<i32>,
// 事件状态
pub status: i32,
// 事件描述
pub desc: String,
// 服务质量
pub qos: Option<i32>,
// 设备信息
pub seller_id: Option<i64>,
pub store_id: Option<i64>,
pub device_id: Option<String>,
......
......@@ -5,12 +5,11 @@ use crate::{
use super::model::TokenInfo;
pub struct Header(pub Option<String>, pub i64, pub i32, pub Qos);
pub trait BusinessEvent {
fn message(
key: Option<String>,
qos: Qos,
msg_id: i64,
msg_ty: i32,
header: Header,
status: Status,
extra: Option<impl AsRef<str>>,
) -> SocketEvent;
......@@ -18,14 +17,11 @@ pub trait BusinessEvent {
impl BusinessEvent for SocketEvent {
fn message(
key: Option<String>,
qos: Qos,
msg_id: i64,
msg_ty: i32,
header: Header,
status: Status,
extra: Option<impl AsRef<str>>,
) -> SocketEvent {
let Header(key, msg_id, msg_ty, qos) = header;
SocketEvent {
seller_id: None,
store_id: None,
......@@ -36,6 +32,7 @@ impl BusinessEvent for SocketEvent {
event: "业务推送事件".to_string(),
event_ty: EventType::BusinessEvent as i32,
key,
qos: Some(qos as i32),
msg_id: Some(msg_id),
msg_ty: Some(msg_ty),
status: status as i32,
......@@ -48,9 +45,7 @@ impl BusinessEvent for SocketEvent {
pub trait PublishEvent {
fn push(
infos: &[TokenInfo],
key: Option<String>,
msg_id: i64,
msg_ty: i32,
header: Header,
status: Status,
desc: impl AsRef<str>,
extra: Option<impl AsRef<str>>,
......@@ -67,13 +62,14 @@ pub trait PublishEvent {
impl PublishEvent for SocketEvent {
fn push(
infos: &[TokenInfo],
key: Option<String>,
msg_id: i64,
msg_ty: i32,
header: Header,
status: Status,
desc: impl AsRef<str>,
extra: Option<impl AsRef<str>>,
) -> Vec<SocketEvent> {
let Header(key, msg_id, msg_ty, qos) = header;
let qos = qos as i32;
let extra = extra.map(|s| s.as_ref().to_string());
let status = status as i32;
......@@ -91,6 +87,7 @@ impl PublishEvent for SocketEvent {
event: "推送事件".to_string(),
event_ty: EventType::PublishEvent as i32,
key: key,
qos: Some(qos),
msg_id: Some(msg_id),
msg_ty: Some(msg_ty),
status,
......@@ -119,6 +116,7 @@ impl PublishEvent for SocketEvent {
event: "推送事件".to_string(),
event_ty: EventType::PublishEvent as i32,
key: None,
qos: None,
msg_id: Some(msg_id),
msg_ty: None,
status: Status::Success as i32,
......@@ -154,6 +152,7 @@ impl ConnectEvent for SocketEvent {
event: "连接事件".to_string(),
event_ty: EventType::ConnectEvent as i32,
key: None,
qos: None,
msg_id: None,
msg_ty: None,
status: status as i32,
......
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