|
|
|
@ -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>;
|
|
|
|
|