update client for oneof messages

This commit is contained in:
Ilion Beyst 2022-07-20 23:43:19 +02:00
parent 73c536b4a6
commit 31f8271db6

View file

@ -57,16 +57,27 @@ async fn run_player(bot_config: BotConfig, player_key: String, channel: Channel)
let (tx, rx) = mpsc::unbounded_channel();
let mut stream = client
.connect_bot(UnboundedReceiverStream::new(rx))
.connect_player(UnboundedReceiverStream::new(rx))
.await
.unwrap()
.into_inner();
while let Some(message) = stream.message().await.unwrap() {
let moves = bot_process.communicate(&message.content).await.unwrap();
tx.send(pb::PlayerRequestResponse {
request_id: message.request_id,
use pb::client_message::ClientMessage;
use pb::server_message::ServerMessage;
match message.server_message {
Some(ServerMessage::PlayerRequest(req)) => {
let moves = bot_process.communicate(&req.content).await.unwrap();
let resp = pb::PlayerRequestResponse {
request_id: req.request_id,
content: moves.as_bytes().to_vec(),
})
.unwrap();
};
let msg = pb::ClientMessage {
client_message: Some(ClientMessage::RequestResponse(resp)),
};
tx.send(msg).unwrap();
}
_ => {} // pass
}
}
}