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 (tx, rx) = mpsc::unbounded_channel();
let mut stream = client let mut stream = client
.connect_bot(UnboundedReceiverStream::new(rx)) .connect_player(UnboundedReceiverStream::new(rx))
.await .await
.unwrap() .unwrap()
.into_inner(); .into_inner();
while let Some(message) = stream.message().await.unwrap() { while let Some(message) = stream.message().await.unwrap() {
let moves = bot_process.communicate(&message.content).await.unwrap(); use pb::client_message::ClientMessage;
tx.send(pb::PlayerRequestResponse { use pb::server_message::ServerMessage;
request_id: message.request_id,
content: moves.as_bytes().to_vec(), match message.server_message {
}) Some(ServerMessage::PlayerRequest(req)) => {
.unwrap(); let moves = bot_process.communicate(&req.content).await.unwrap();
let resp = pb::PlayerRequestResponse {
request_id: req.request_id,
content: moves.as_bytes().to_vec(),
};
let msg = pb::ClientMessage {
client_message: Some(ClientMessage::RequestResponse(resp)),
};
tx.send(msg).unwrap();
}
_ => {} // pass
}
} }
} }