mirror of
https://github.com/OMGeeky/gdriver2.git
synced 2026-02-15 22:14:31 +01:00
Initial prototype
This prototype has basic IPC working, with starting actions and waiting for actions or just getting information
This commit is contained in:
32
gdriver-client/src/sample.rs
Normal file
32
gdriver-client/src/sample.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use gdriver_common::config::CONFIGURATION;
|
||||
|
||||
use super::*;
|
||||
pub async fn start() -> Result<()> {
|
||||
println!("Hello, world!");
|
||||
|
||||
let name = "test1".to_string();
|
||||
let config = &CONFIGURATION;
|
||||
let client: WorldClient = create_client(config.ip, config.port).await?;
|
||||
|
||||
let hello = client
|
||||
.hello(tarpc::context::current(), name.to_string())
|
||||
.await;
|
||||
|
||||
match hello {
|
||||
Ok(hello) => println!("{hello:?}"),
|
||||
Err(e) => println!("{:?}", (e)),
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub async fn create_client(ip: IpAddr, port: u16) -> Result<WorldClient> {
|
||||
let server_addr = (ip, port);
|
||||
let transport = tarpc::serde_transport::tcp::connect(&server_addr, Json::default)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
println!("Could not connect");
|
||||
e
|
||||
})?;
|
||||
let var_name = WorldClient::new(client::Config::default(), transport);
|
||||
let client = var_name.spawn();
|
||||
Ok(client)
|
||||
}
|
||||
Reference in New Issue
Block a user