Browse Source

Add Todo state to LoginStatus enum.

wip
Titouan Rigoudy 6 years ago
parent
commit
2d4813d047
2 changed files with 11 additions and 6 deletions
  1. +8
    -3
      src/client.rs
  2. +3
    -3
      src/login.rs

+ 8
- 3
src/client.rs View File

@ -72,7 +72,7 @@ impl Client {
control_tx: None,
control_rx: control_rx,
login_status: LoginStatus::Pending,
login_status: LoginStatus::Todo,
rooms: room::RoomMap::new(),
users: user::UserMap::new(),
@ -94,6 +94,8 @@ impl Client {
.unwrap(),
));
self.login_status = LoginStatus::AwaitingResponse;
self.send_to_server(server::ServerRequest::SetListenPortRequest(
server::SetListenPortRequest {
port: config::LISTEN_PORT,
@ -210,7 +212,10 @@ impl Client {
let username = config::USERNAME.to_string();
let response = match self.login_status {
LoginStatus::Pending => control::LoginStatusResponse::Pending { username: username },
LoginStatus::Todo => control::LoginStatusResponse::Pending { username: username },
LoginStatus::AwaitingResponse => {
control::LoginStatusResponse::Pending { username: username }
}
LoginStatus::Success(ref motd) => control::LoginStatusResponse::Success {
username: username,
@ -528,7 +533,7 @@ impl Client {
}
fn handle_login_response(&mut self, login: server::LoginResponse) {
if let LoginStatus::Pending = self.login_status {
if let LoginStatus::AwaitingResponse = self.login_status {
match login {
server::LoginResponse::LoginOk {
motd,


+ 3
- 3
src/login.rs View File

@ -6,10 +6,11 @@
/// successfully logged in, the client can interact with the server.
#[derive(Clone, Debug)]
pub enum LoginStatus {
// TODO: add a state representing the fact that no request has been sent.
/// Request not sent yet.
Todo,
/// Sent request, awaiting response.
Pending,
AwaitingResponse,
/// Logged in.
/// Stores the MOTD as received from the server.
@ -19,4 +20,3 @@ pub enum LoginStatus {
/// Stores the error message as received from the server.
Failure(String),
}

Loading…
Cancel
Save