Skip to content

Commit

Permalink
Good work kevin, added webapp and server
Browse files Browse the repository at this point in the history
  • Loading branch information
kkevlar committed Apr 29, 2024
1 parent df8dd70 commit ad1d4c8
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 66 deletions.
131 changes: 69 additions & 62 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["ui_demo", "mjoy_core"]
members = ["ui_demo", "mjoy_core", "command_server"]
18 changes: 18 additions & 0 deletions command_server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "command_sever"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
serde_json = "1.0.116"

[lib]
name = "command_server"
path = "src/lib.rs"

[[example]]
name = "helloworld"
path = "examples/helloworld.rs"

24 changes: 24 additions & 0 deletions command_server/examples/helloworld.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use command_server;
use std::sync::mpsc::channel;
use std::thread;

fn main() {
// Create a channel for sending commands to the library
let (sender, receiver) = channel();

// Start the library's server in a separate thread
thread::spawn(move || {
if let Err(err) = command_server::field_commands_forever(sender) {
eprintln!("Error in library: {:?}", err);
}
});

// Main thread can now handle received commands or perform other tasks
// For demonstration, let's just print received commands
for received_cmd in receiver {
println!("Received command: {:?}", received_cmd);
// Implement your logic to handle the received commands here
}

// Optionally, you can perform cleanup or other tasks before exiting
}
Loading

0 comments on commit ad1d4c8

Please sign in to comment.