Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3513724
D5534.id18243.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D5534.id18243.diff
View Options
diff --git a/services/tunnelbroker/src/cxx_bridge.rs b/services/tunnelbroker/src/cxx_bridge.rs
--- a/services/tunnelbroker/src/cxx_bridge.rs
+++ b/services/tunnelbroker/src/cxx_bridge.rs
@@ -40,5 +40,9 @@
sessionID: &str,
isOnline: bool,
) -> Result<()>;
+ pub fn updateSessionItemDeviceToken(
+ sessionID: &str,
+ newNotifToken: &str,
+ ) -> Result<()>;
}
}
diff --git a/services/tunnelbroker/src/libcpp/Tunnelbroker.h b/services/tunnelbroker/src/libcpp/Tunnelbroker.h
--- a/services/tunnelbroker/src/libcpp/Tunnelbroker.h
+++ b/services/tunnelbroker/src/libcpp/Tunnelbroker.h
@@ -15,3 +15,4 @@
rust::Str notifyToken);
SessionItem getSessionItem(rust::Str sessionID);
void updateSessionItemIsOnline(rust::Str sessionID, bool isOnline);
+void updateSessionItemDeviceToken(rust::Str sessionID, rust::Str newNotifToken);
diff --git a/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp b/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
--- a/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
+++ b/services/tunnelbroker/src/libcpp/Tunnelbroker.cpp
@@ -161,3 +161,11 @@
comm::network::database::DatabaseManager::getInstance()
.updateSessionItemIsOnline(std::string{sessionID}, isOnline);
}
+
+void updateSessionItemDeviceToken(
+ rust::Str sessionID,
+ rust::Str newNotifToken) {
+ comm::network::database::DatabaseManager::getInstance()
+ .updateSessionItemDeviceToken(
+ std::string{sessionID}, std::string{newNotifToken});
+}
diff --git a/services/tunnelbroker/src/server/mod.rs b/services/tunnelbroker/src/server/mod.rs
--- a/services/tunnelbroker/src/server/mod.rs
+++ b/services/tunnelbroker/src/server/mod.rs
@@ -1,16 +1,19 @@
use super::constants;
use super::cxx_bridge::ffi::{
getSessionItem, newSessionHandler, sessionSignatureHandler,
- updateSessionItemIsOnline,
+ updateSessionItemDeviceToken, updateSessionItemIsOnline,
};
use anyhow::Result;
use futures::Stream;
use std::pin::Pin;
use tokio::sync::mpsc;
use tokio::time::{sleep, Duration};
-use tokio_stream::wrappers::ReceiverStream;
+use tokio_stream::{wrappers::ReceiverStream, StreamExt};
use tonic::{transport::Server, Request, Response, Status, Streaming};
-use tracing::debug;
+use tracing::{debug, error};
+use tunnelbroker::message_to_tunnelbroker::Data::{
+ MessagesToSend, NewNotifyToken, ProcessedMessages,
+};
use tunnelbroker::tunnelbroker_service_server::{
TunnelbrokerService, TunnelbrokerServiceServer,
};
@@ -147,6 +150,39 @@
}
});
+ let mut input_stream = request.into_inner();
+ // Spawning asynchronous Tokio task for handling incoming messages from the client
+ tokio::spawn(async move {
+ while let Some(result) = input_stream.next().await {
+ if let Err(err) = result {
+ debug!("Error in input stream: {}", err);
+ break;
+ }
+ if let Some(message_data) = result.unwrap().data {
+ match message_data {
+ NewNotifyToken(new_token) => {
+ if let Err(err) =
+ updateSessionItemDeviceToken(&session_id, &new_token)
+ {
+ error!(
+ "Error in updating the device notification token in the database: {}",
+ err.what()
+ );
+ }
+ }
+ MessagesToSend(_) => (),
+ ProcessedMessages(_) => (),
+ }
+ }
+ }
+ if let Err(err) = updateSessionItemIsOnline(&session_id, false) {
+ error!(
+ "Error in updating the session online state in the database: {}",
+ err.what()
+ );
+ }
+ });
+
let output_stream = ReceiverStream::new(rx);
Ok(Response::new(
Box::pin(output_stream) as Self::MessagesStreamStream
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 1:54 AM (17 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2693126
Default Alt Text
D5534.id18243.diff (3 KB)
Attached To
Mode
D5534: [services] Tunnelbroker - Adding of handling of the `NewNotifyToken` message
Attached
Detach File
Event Timeline
Log In to Comment