Skip to content

Commit

Permalink
base done
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGruber committed Dec 8, 2023
1 parent 9add677 commit a887d7e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
52 changes: 52 additions & 0 deletions src/soeprotocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,57 @@ impl Soeprotocol {
SoeOpcode::SessionRequest,
SoePacket::SessionRequestPacket(self.parse_session_request(rdr)),
),
SoeOpcode::SessionReply => SoePacketParsed::new(
SoeOpcode::SessionReply,
SoePacket::SessionReplyPacket(self.parse_session_reply(rdr)),
),
SoeOpcode::MultiPacket => SoePacketParsed::new(
SoeOpcode::MultiPacket,
SoePacket::GroupedPackets(self.parse_multi(rdr)),
),
SoeOpcode::Disconnect => SoePacketParsed::new(
SoeOpcode::Disconnect,
SoePacket::DisconnectPacket(self.parse_disconnect(rdr)),
),
SoeOpcode::Ping => {
SoePacketParsed::new(SoeOpcode::Ping, SoePacket::PingPacket(PingPacket {}))
}
SoeOpcode::NetStatusRequest => SoePacketParsed::new(
SoeOpcode::NetStatusRequest,
SoePacket::NetStatusRequestPacket(self.parse_net_status_request(rdr)),
),
SoeOpcode::NetStatusReply => SoePacketParsed::new(
SoeOpcode::NetStatusReply,
SoePacket::NetStatusReplyPacket(self.parse_net_status_reply(rdr)),
),
SoeOpcode::Data => SoePacketParsed::new(
SoeOpcode::Data,
SoePacket::DataPacket(self.parse_data(rdr, opcode as u16)),
),
SoeOpcode::DataFragment => SoePacketParsed::new(
SoeOpcode::DataFragment,
SoePacket::DataPacket(self.parse_data(rdr, opcode as u16)),
),
SoeOpcode::OutOfOrder => SoePacketParsed::new(
SoeOpcode::OutOfOrder,
SoePacket::AckPacket(self.parse_ack(rdr, opcode as u16)),
),
SoeOpcode::Ack => SoePacketParsed::new(
SoeOpcode::Ack,
SoePacket::AckPacket(self.parse_ack(rdr, opcode as u16)),
),
SoeOpcode::Group => SoePacketParsed::new(
SoeOpcode::Group,
SoePacket::GroupedPackets(self.parse_multi(rdr)),
),
SoeOpcode::Ordered => SoePacketParsed::new(
SoeOpcode::Ordered,
SoePacket::DataPacket(self.parse_data(rdr, opcode as u16)),
),
SoeOpcode::FatalError => SoePacketParsed::new(
SoeOpcode::FatalError,
SoePacket::FatalErrorPacket(FatalErrorPacket {}),
),
}
}

Expand Down Expand Up @@ -676,6 +727,7 @@ impl Soeprotocol {
}

fn parse_multi(&mut self, mut rdr: Cursor<&std::vec::Vec<u8>>) -> GroupedPackets {
todo!();
// check size
// if !check_min_size(
// &rdr,
Expand Down
6 changes: 5 additions & 1 deletion src/soeprotocol_packets_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub enum SoePacket {
NetStatusRequestPacket(NetStatusRequestPacket),
GroupedPackets(GroupedPackets),
PingPacket(PingPacket),
FatalErrorPacket(FatalErrorPacket),
DisconnectPacket(DisconnectPacket),
UnknownPacket(UnknownPacket),
}
Expand Down Expand Up @@ -94,7 +95,10 @@ pub struct UnknownPacket {}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PingPacket {}
#[wasm_bindgen]
impl PingPacket {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FatalErrorPacket {}
#[wasm_bindgen]
impl FatalErrorPacket {
#[wasm_bindgen(constructor)]
pub fn new() -> Self {
Self {}
Expand Down

0 comments on commit a887d7e

Please sign in to comment.