Browse Source

Extract LoginStatus to its own file.

wip
Titouan Rigoudy 6 years ago
parent
commit
64472daae9
3 changed files with 24 additions and 7 deletions
  1. +1
    -7
      src/client.rs
  2. +22
    -0
      src/login.rs
  3. +1
    -0
      src/main.rs

+ 1
- 7
src/client.rs View File

@ -6,6 +6,7 @@ use slab;
use crate::config; use crate::config;
use crate::control; use crate::control;
use crate::login::LoginStatus;
use crate::proto; use crate::proto;
use crate::proto::peer; use crate::proto::peer;
use crate::proto::server; use crate::proto::server;
@ -18,13 +19,6 @@ enum IncomingMessage {
ControlNotification(control::Notification), ControlNotification(control::Notification),
} }
#[derive(Clone, Debug)]
enum LoginStatus {
Pending,
Success(String),
Failure(String),
}
#[derive(Debug)] #[derive(Debug)]
enum PeerState { enum PeerState {
/// We are trying to establish a direct connection. /// We are trying to establish a direct connection.


+ 22
- 0
src/login.rs View File

@ -0,0 +1,22 @@
/// Represents the status of the login operation.
///
/// In order to interact with the server, a client cannot simply open a network
/// connection. Instead, it must send a login request with basic credentials.
/// The server is supposed the respond with a success or error message. Once
/// 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.
/// Sent request, awaiting response.
Pending,
/// Logged in.
/// Stores the MOTD as received from the server.
Success(String),
/// Failed to log in.
/// Stores the error message as received from the server.
Failure(String),
}

+ 1
- 0
src/main.rs View File

@ -14,6 +14,7 @@ mod control;
mod dispatcher; mod dispatcher;
mod executor; mod executor;
mod handlers; mod handlers;
mod login;
mod message_handler; mod message_handler;
mod proto; mod proto;
mod room; mod room;


Loading…
Cancel
Save