Page MenuHomePhabricator

D6284.id21001.diff
No OneTemporary

D6284.id21001.diff

diff --git a/shared/tunnelbroker-client/src/lib.rs b/shared/tunnelbroker-client/src/lib.rs
--- a/shared/tunnelbroker-client/src/lib.rs
+++ b/shared/tunnelbroker-client/src/lib.rs
@@ -1,3 +1,4 @@
+use futures_util::stream;
use lazy_static::lazy_static;
use std::sync::Arc;
use tokio::runtime::{Builder, Runtime};
@@ -26,3 +27,26 @@
.block_on(TunnelbrokerServiceClient::connect(addr))
.expect("Failed to create Tokio runtime for the Tunnelbroker client")
}
+
+pub async fn publish_messages<T>(
+ client: &mut TunnelbrokerServiceClient<Channel>,
+ to_device_id: String,
+ payload: String,
+) -> anyhow::Result<()> {
+ let messages = vec![tunnelbroker::MessageToTunnelbroker {
+ data: Some(tunnelbroker::message_to_tunnelbroker::Data::MessagesToSend(
+ tunnelbroker::MessagesToSend {
+ messages: vec![tunnelbroker::MessageToTunnelbrokerStruct {
+ to_device_id,
+ payload,
+ blob_hashes: vec![],
+ }],
+ },
+ )),
+ }];
+ client
+ .messages_stream(stream::iter(messages))
+ .await
+ .expect("Failed to send messages to the Tunnelbroker stream");
+ Ok(())
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 6:39 AM (1 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675740
Default Alt Text
D6284.id21001.diff (1 KB)

Event Timeline