fix: message not send

- add target send

Signed-off-by: Pakin <pakin.t@forth.co.th>
This commit is contained in:
Pakin 2026-04-28 17:18:03 +07:00
parent da956d39a7
commit 295f69a34c
3 changed files with 15 additions and 5 deletions

View file

@ -26,6 +26,13 @@ impl IntoStreamMessage for StreamDataStart {
const MSG_NAME: &str = "stream_data_start";
fn build(&self) -> serde_json::Value {
let mut payload = serde_json::to_value(self).unwrap();
payload.as_object_mut().unwrap().insert(
"to".to_string(),
serde_json::json!(self.stream_ref.clone().unwrap_or_default()),
);
serde_json::json!({
"type": StreamDataStart::MSG_NAME,
"payload": self.clone()
@ -61,6 +68,7 @@ pub struct StreamDataChunk<T> {
pub start_idx: usize,
/// Chunked data which splited into N items per chunk
pub data: Vec<T>,
#[serde(rename = "to")]
uid: String,
}
@ -142,6 +150,7 @@ pub struct StreamDataExtra<T> {
pub exid: String,
pub extp: String,
pub payload: Vec<T>,
pub to: String,
}
impl<T> IntoStreamMessage for StreamDataExtra<T>
@ -166,11 +175,12 @@ impl<T> StreamDataExtra<T>
where
T: Serialize + Clone,
{
pub fn new(exid: &str, extp: &str, data: Vec<T>) -> Self {
pub fn new(exid: &str, extp: &str, data: Vec<T>, to: String) -> Self {
Self {
exid: exid.to_string(),
extp: extp.to_string(),
payload: data.to_vec(),
to,
}
}