Browse Source

Refactor proto module.

wip
Titouan Rigoudy 9 years ago
parent
commit
353d926383
5 changed files with 8 additions and 11 deletions
  1. +1
    -1
      src/main.rs
  2. +0
    -5
      src/proto/connection.rs
  3. +3
    -1
      src/proto/mod.rs
  4. +1
    -1
      src/proto/server.rs
  5. +3
    -3
      src/server.rs

+ 1
- 1
src/main.rs View File

@ -13,7 +13,7 @@ use std::net::ToSocketAddrs;
use mio::{EventLoop, EventSet, Handler, PollOpt, Token};
use mio::tcp::TcpStream;
use proto::connection::Connection;
use proto::Connection;
use server::ServerConnection;
const SERVER_TOKEN : Token = Token(0);


+ 0
- 5
src/proto/connection.rs View File

@ -4,14 +4,12 @@ use std::io::{Cursor, Read, Write};
use std::mem;
use byteorder::{ByteOrder, LittleEndian, ReadBytesExt, WriteBytesExt};
use mio::tcp::TcpStream;
const MAX_PACKET_SIZE: usize = 1 << 20; // 1 MiB
const U32_SIZE: usize = 4;
const MAX_MESSAGE_SIZE: usize = MAX_PACKET_SIZE - U32_SIZE;
const CODE_LOGIN: u32 = 1;
#[derive(Debug)]
pub struct Packet {
@ -121,9 +119,6 @@ impl io::Read for Packet {
}
/*======*
* PEER *
*======*/
pub trait Peer {
fn read_packet(&mut self) -> Option<Packet>;


+ 3
- 1
src/proto/mod.rs View File

@ -1,2 +1,4 @@
pub mod connection;
mod connection;
pub mod server;
pub use self::connection::{Connection, Packet, Peer};

+ 1
- 1
src/proto/server.rs View File

@ -4,7 +4,7 @@ use std::net;
use crypto::md5::Md5;
use crypto::digest::Digest;
use proto::connection::Packet;
use super::Packet;
const VERSION_MAJOR: u32 = 181;
const VERSION_MINOR: u32 = 0;


+ 3
- 3
src/server.rs View File

@ -1,7 +1,9 @@
use std::io;
use std::net::Ipv4Addr;
use proto::connection::{Packet, Peer};
use config;
use proto::{Peer, Packet};
use proto::server::{
LoginRequest,
LoginResponse,
@ -9,8 +11,6 @@ use proto::server::{
ServerResponse,
};
use config;
#[derive(Debug, Clone, Copy)]
enum State {
NotLoggedIn,


Loading…
Cancel
Save