From ebe858256fba96be5b98f2eee21ee974cbc4885a Mon Sep 17 00:00:00 2001 From: Rakowskiii <38994251+Rakowskiii@users.noreply.github.com> Date: Wed, 14 Jun 2023 16:14:00 +0200 Subject: [PATCH] feat: add tag field to PublishedMessage (#26) --- relay_client/src/websocket.rs | 6 +++++- relay_client/src/websocket/inbound.rs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/relay_client/src/websocket.rs b/relay_client/src/websocket.rs index 418a021..37b71a0 100644 --- a/relay_client/src/websocket.rs +++ b/relay_client/src/websocket.rs @@ -2,7 +2,7 @@ use { self::connection::{connection_event_loop, ConnectionControl}, crate::{error::Error, ConnectionOptions}, relay_rpc::{ - domain::{SubscriptionId, Topic}, + domain::{MessageId, SubscriptionId, Topic}, rpc::{ BatchFetchMessages, BatchReceiveMessages, @@ -74,8 +74,10 @@ mod stream; /// The message received from a subscription. #[derive(Debug)] pub struct PublishedMessage { + pub id: MessageId, pub topic: Topic, pub message: Arc, + pub tag: u32, pub published_at: chrono::DateTime, pub received_at: chrono::DateTime, } @@ -86,8 +88,10 @@ impl PublishedMessage { let now = chrono::Utc::now(); Self { + id: request.id(), topic: data.topic.clone(), message: data.message.clone(), + tag: data.tag, // TODO: Set proper value once implemented. published_at: now, received_at: now, diff --git a/relay_client/src/websocket/inbound.rs b/relay_client/src/websocket/inbound.rs index ac2b4f2..f5d28bf 100644 --- a/relay_client/src/websocket/inbound.rs +++ b/relay_client/src/websocket/inbound.rs @@ -35,6 +35,10 @@ where &self.data } + pub fn id(&self) -> MessageId { + self.id + } + /// Sends the response back to the Relay. The value is a /// `Result` (see [`RequestPayload`] trait for /// details).