Page MenuHomePhabricator

D6284.id21553.diff
No OneTemporary

D6284.id21553.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,6 +1,8 @@
+use anyhow::Result;
use lazy_static::lazy_static;
use std::sync::Arc;
use tokio::runtime::{Builder, Runtime};
+use tokio::sync::mpsc;
use tonic::transport::Channel;
pub mod protobuff {
@@ -26,3 +28,23 @@
.block_on(TunnelbrokerServiceClient::connect(addr))
.expect("Failed to connect ot the Tunnelbroker Service")
}
+
+pub async fn publish_message(
+ tx: &mpsc::Sender<protobuff::MessageToTunnelbroker>,
+ to_device_id: String,
+ payload: String,
+) -> Result<()> {
+ let messages = protobuff::MessageToTunnelbroker {
+ data: Some(protobuff::message_to_tunnelbroker::Data::MessagesToSend(
+ protobuff::MessagesToSend {
+ messages: vec![protobuff::MessageToTunnelbrokerStruct {
+ to_device_id,
+ payload,
+ blob_hashes: vec![],
+ }],
+ },
+ )),
+ };
+ tx.send(messages).await?;
+ Ok(())
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 7:27 AM (21 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675869
Default Alt Text
D6284.id21553.diff (1 KB)

Event Timeline