Browse Source

start of gamemessage

pull/3/head
jake 5 years ago
parent
commit
a442a34a2c
  1. 12
      src/packet/messages.rs

12
src/packet/messages.rs

@ -19,23 +19,25 @@ pub struct PlayerWalking {
}
pub enum Message {
#[derive(Debug, Clone, PartialEq)]
pub enum GameMessage {
PlayerWalking(PlayerWalking),
}
impl PSOPacketData for Message {
impl PSOPacketData for GameMessage {
fn from_bytes<R: std::io::Read + std::io::Seek>(mut cur: &mut R) -> Result<Self, PacketParseError> {
let mut byte = [0u8; 1];
cur.read(&mut byte);
cur.seek(SeekFrom::Current(-1)); // Cursor doesn't implement Peek?
match byte[0] {
PlayerWalking::CMD => Ok(Message::PlayerWalking(PlayerWalking::from_bytes(&mut cur)?)),
PlayerWalking::CMD => Ok(GameMessage::PlayerWalking(PlayerWalking::from_bytes(&mut cur)?)),
_ => Err(PacketParseError::WrongPacketCommand),
}
}
fn as_bytes(&self) -> Vec<u8> {
Vec::new()
match self {
GameMessage::PlayerWalking(data) => data.as_bytes(),
}
}
}

Loading…
Cancel
Save