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)]
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,
/// 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,
/// The controller wants to join a room. Contains the room name.
JoinRoomRequest(String),
/// The controller wants to know what the login status is.
LoginStatusRequest,
/// The controller wants to know the list of visible chat rooms.
RoomListRequest,
}

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

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

Loading…
Cancel
Save