mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-28 11:10:44 +01:00
feat: add game loop
sending and receiving moves from server, client implementation of this in a simple cli
This commit is contained in:
@@ -237,6 +237,24 @@ impl Client {
|
||||
});
|
||||
}
|
||||
|
||||
pub async fn send_capture(&mut self, capture: CapturePath) {
|
||||
debug!("Requesting sending capture: {:?}", capture);
|
||||
if let Some(sender) = &self.commands_sender {
|
||||
let _ = sender.send(ClientCommands::SendCapture(capture)).await;
|
||||
} else {
|
||||
error!("Command sender not set!");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn send_move(&mut self, from: Position, to: Position) {
|
||||
debug!("Requested sending move from: {} to: {}", from, to);
|
||||
if let Some(sender) = &self.commands_sender {
|
||||
let _ = sender.send(ClientCommands::SendMove { from, to }).await;
|
||||
} else {
|
||||
error!("Command sender not set!");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn send_text_message(&mut self, content: String) {
|
||||
if let Some(sender) = &self.commands_sender {
|
||||
let _ = sender.send(ClientCommands::SendText(content)).await;
|
||||
|
||||
Reference in New Issue
Block a user