Browse Source

Comment control::request and control::response.

wip
Titouan Rigoudy 9 years ago
parent
commit
dec759a475
2 changed files with 26 additions and 0 deletions
  1. +10
    -0
      src/control/request.rs
  2. +16
    -0
      src/control/response.rs

+ 10
- 0
src/control/request.rs View File

@ -1,8 +1,18 @@
/// This enumeration is the list of possible control requests made by the
/// controller client to the client.
#[derive(Debug, RustcDecodable, RustcEncodable)] #[derive(Debug, RustcDecodable, RustcEncodable)]
pub enum Request { pub enum Request {
/// Not a real request: this is to notify the client that a controller is
/// now connected, and control responses can now be sent.
ConnectNotification, ConnectNotification,
/// Not a real request: this is to notify the client that the controller has
/// now disconnected, and control responses should no longer be
/// sent.
DisconnectNotification, DisconnectNotification,
/// The controller wants to join a room. Contains the room name.
JoinRoomRequest(String), JoinRoomRequest(String),
/// The controller wants to know what the login status is.
LoginStatusRequest, LoginStatusRequest,
/// The controller wants to know the list of visible chat rooms.
RoomListRequest, RoomListRequest,
} }

+ 16
- 0
src/control/response.rs View File

@ -1,29 +1,45 @@
use room; use room;
/// This enumeration is the list of possible control responses from the client
/// to the controller.
#[derive(Debug, RustcDecodable, RustcEncodable)] #[derive(Debug, RustcDecodable, RustcEncodable)]
pub enum Response { pub enum Response {
LoginStatusResponse(LoginStatusResponse), LoginStatusResponse(LoginStatusResponse),
RoomListResponse(RoomListResponse), RoomListResponse(RoomListResponse),
} }
/// This enumeration is the list of possible login states, and the associated
/// information.
#[derive(Debug, RustcDecodable, RustcEncodable)] #[derive(Debug, RustcDecodable, RustcEncodable)]
pub enum LoginStatusResponse { pub enum LoginStatusResponse {
/// The login request has been sent to the server, but the response hasn't
/// been received yet.
Pending { Pending {
/// The username used to log in.
username: String, username: String,
}, },
/// Login was successful.
Success { Success {
/// The username used to log in.
username: String, username: String,
/// The message of the day sent by the server.
motd: String, motd: String,
}, },
/// Login failed.
Failure { Failure {
/// The username used to log in.
username: String, username: String,
/// The reason the server gave for refusing the login request.
reason: String, reason: String,
} }
} }
/// This structure contains the list of all visible rooms, and their associated
/// data.
#[derive(Debug, RustcDecodable, RustcEncodable)] #[derive(Debug, RustcDecodable, RustcEncodable)]
pub struct RoomListResponse { pub struct RoomListResponse {
/// The list of (room name, room data) pairs.
pub rooms: Vec<(String, room::Room)>, pub rooms: Vec<(String, room::Room)>,
} }

Loading…
Cancel
Save