use crate::NAME;
use gipc::connection::Connection;
pub fn main() {
println!("[client] Connecting to socket {}", NAME);
let mut connection =
Connection::connect_to_socket(NAME, false).expect("Connection should connect properly");
let greeting: String = connection
.receive()
.expect("Couldn't receive greeting from server!");
if greeting == "Hello, client!" {
println!("[client] Yay, the server greeted me! I'll greet them back.");
connection
.send(&"Hello, server!")
.expect("Couldn't send greeting to server!");
}
let weather: String = connection
.send_and_receive(&"What's the weather like today?")
.expect("Could not ask what the weather was!");
println!(
"[client] The weather is apparently {}. That's nice!",
weather
);
connection
.send(&"That's nice!")
.expect("Could not respond with thoughts on the weather!");
connection.close();
}