sc2_proxy/remote_control/
message.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Messages for the remote control protocol

use serde::{Deserialize, Serialize};

use crate::config::Config;
use crate::supervisor::GameId;

/// Request to the client, always gets a Response
/// Currently client identifiers are string containg the peer address and port
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum Request {
    /// Shut down the proxy
    Quit,
    /// Check that the system is up and synchronized
    Ping(u32),
    /// Read current server configuration
    GetConfig,
    /// Update configuration for the new games
    SetConfig(Config),
    /// Get identifiers and ready statuses of all clients in the playlist
    GetPlaylist,
    /// Remove a client from the playlist by identifier
    DropPlaylistItem(String),
    /// Remove all clients from the playlist
    ClearPlaylist,
    /// Creates a new lobby with given players
    CreateLobby,
    /// Moves player from the playlist to a lobby by identifier
    AddToLobby(GameId, String),
    /// Starts a game from lobby
    StartGame(GameId),
}

/// Response to a Request
#[allow(missing_docs)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum Response {
    Error(String),
    Quit,
    Ping(u32),
    GetConfig(Config),
    SetConfig(Config),
    /// Vec of identifier and is_ready
    GetPlaylist(Vec<(String, bool)>),
    DropPlaylist,
    ClearPlaylist,
    CreateLobby(GameId),
    AddToLobby,
    StartGame,
}

/// Asychronous update to a Request
/// This can be used for e.g. realtime updates of score values
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub enum Update {}