Skip to main content

nil_client/client/
round.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use super::Client;
5use crate::error::Result;
6use crate::http;
7use nil_core::round::Round;
8use nil_payload::round::*;
9
10impl Client {
11  pub async fn get_round(&self, req: GetRoundRequest) -> Result<Round> {
12    http::json_put("get-round")
13      .body(req)
14      .server(self.server)
15      .circuit_breaker(self.circuit_breaker())
16      .retry(&self.retry)
17      .user_agent(&self.user_agent)
18      .send()
19      .await
20  }
21
22  pub async fn set_player_ready(&self, req: SetPlayerReadyRequest) -> Result<Round> {
23    http::json_post("set-player-ready")
24      .body(req)
25      .server(self.server)
26      .maybe_authorization(self.authorization.as_ref())
27      .circuit_breaker(self.circuit_breaker())
28      .user_agent(&self.user_agent)
29      .send()
30      .await
31  }
32
33  pub async fn start_round(&self, req: StartRoundRequest) -> Result<Round> {
34    http::json_post("start-round")
35      .body(req)
36      .server(self.server)
37      .maybe_authorization(self.authorization.as_ref())
38      .circuit_breaker(self.circuit_breaker())
39      .user_agent(&self.user_agent)
40      .send()
41      .await
42  }
43}