Skip to content

Commit 46e8be5

Browse files
committed
Minor fix to dora tcp
1 parent f7d709a commit 46e8be5

5 files changed

Lines changed: 24 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ members = [
3939
"node-hub/dora-mistral-rs",
4040
"node-hub/dora-rav1e",
4141
"node-hub/dora-dav1d",
42+
"node-hub/dora-tcp",
4243
"libraries/extensions/ros2-bridge",
4344
"libraries/extensions/ros2-bridge/msg-gen",
4445
"libraries/extensions/ros2-bridge/python",

node-hub/dora-tcp/cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ repository.workspace = true
1010
[dependencies]
1111
dora-node-api = { workspace = true }
1212
tokio = { version = "1.45.0", features = ["full"] }
13+
eyre = "0.6.8"

node-hub/dora-tcp/src/lib.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
Basic TCP implementation for streaming events to a TCP Destination
33
*/
44
use dora_node_api::{DoraNode, Event};
5+
use eyre::Result;
56
use tokio::io::AsyncWriteExt;
67
use tokio::net::TcpStream;
7-
use std::error::Error;
8-
9-
10-
#[tokio::main]
11-
async fn main() -> Result<(), Box<dyn Error>> {
128

9+
pub async fn lib_main() -> Result<()> {
1310
// NOTE: Hard-coded address
14-
let mut stream = TcpStream::connect("localhost:8052").await?;
11+
let mut stream =
12+
TcpStream::connect(std::env::var("ADDR").unwrap_or("127.0.0.1:8052".to_string())).await?;
1513

1614
let (_, mut events) = DoraNode::init_from_env()?;
1715

@@ -22,14 +20,13 @@ async fn main() -> Result<(), Box<dyn Error>> {
2220
metadata: _,
2321
data,
2422
} => match id.as_str() {
25-
"command" => {
26-
23+
"text" => {
2724
// Extract the command
2825
let command: &str = (&data).try_into()?;
2926

3027
// Send the command to the Unity over tcp
3128
stream.write_all(command.as_bytes()).await?;
32-
},
29+
}
3330
_ => {}
3431
},
3532
_ => {}

node-hub/dora-tcp/src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[tokio::main]
2+
3+
async fn main() -> Result<(), eyre::Error> {
4+
dora_tcp::lib_main().await
5+
}

0 commit comments

Comments
 (0)