-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Good work kevin, added webapp and server
- Loading branch information
Showing
9 changed files
with
356 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.