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_post("get-round")
13      .body(req)
14      .server(self.server)
15      .user_agent(&self.user_agent)
16      .send()
17      .await
18  }
19
20  pub async fn set_player_ready(&self, req: SetPlayerReadyRequest) -> Result<Round> {
21    http::json_post("set-player-ready")
22      .body(req)
23      .server(self.server)
24      .maybe_authorization(self.authorization.as_ref())
25      .user_agent(&self.user_agent)
26      .send()
27      .await
28  }
29
30  pub async fn start_round(&self, req: StartRoundRequest) -> Result<Round> {
31    http::json_post("start-round")
32      .body(req)
33      .server(self.server)
34      .maybe_authorization(self.authorization.as_ref())
35      .user_agent(&self.user_agent)
36      .send()
37      .await
38  }
39}