Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion relay_client/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
auth::ed25519_dalek::Keypair,
domain::{DecodedClientId, SubscriptionId, Topic},
jwt::{self, JwtError, VerifyableClaims},
rpc::{self, RequestPayload},
rpc::{self, Receipt, RequestPayload},
},
std::{sync::Arc, time::Duration},
url::Url,
Expand Down Expand Up @@ -247,6 +247,17 @@ impl Client {
.await
}

/// Acknowledge receipt of messages from a subscribed client.
pub async fn batch_receive(
&self,
receipts: impl Into<Vec<Receipt>>,
) -> Response<rpc::BatchReceiveMessages> {
self.request(rpc::BatchReceiveMessages {
receipts: receipts.into(),
})
.await
}

pub(crate) async fn request<T>(&self, payload: T) -> Response<T>
where
T: RequestPayload,
Expand Down
16 changes: 16 additions & 0 deletions relay_client/src/websocket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ use {
domain::{SubscriptionId, Topic},
rpc::{
BatchFetchMessages,
BatchReceiveMessages,
BatchSubscribe,
BatchUnsubscribe,
FetchMessages,
Publish,
Receipt,
Subscribe,
Subscription,
Unsubscribe,
Expand Down Expand Up @@ -231,6 +233,20 @@ impl Client {
response
}

/// Acknowledge receipt of messages from a subscribed client.
pub async fn batch_receive(
&self,
receipts: impl Into<Vec<Receipt>>,
) -> ResponseFuture<BatchReceiveMessages> {
let (request, response) = create_request(BatchReceiveMessages {
receipts: receipts.into(),
});

self.request(request);

response
}

/// Opens a connection to the Relay.
pub async fn connect(&self, opts: &ConnectionOptions) -> Result<(), Error> {
let (tx, rx) = oneshot::channel();
Expand Down