1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-30 11:47:45 +00:00
kawari/src/ipc/chat/mod.rs

50 lines
1.1 KiB
Rust
Raw Normal View History

2025-05-01 23:34:06 -04:00
use binrw::binrw;
use crate::{
opcodes::ServerChatIpcType,
packet::{IpcSegment, ReadWriteIpcSegment},
};
pub type ServerChatIpcSegment = IpcSegment<ServerChatIpcType, ServerChatIpcData>;
impl ReadWriteIpcSegment for ServerChatIpcSegment {
fn calc_size(&self) -> u32 {
// 16 is the size of the IPC header
16 + self.op_code.calc_size()
}
fn get_name(&self) -> &'static str {
self.op_code.get_name()
}
2025-05-01 23:34:06 -04:00
}
// TODO: make generic
impl Default for ServerChatIpcSegment {
fn default() -> Self {
Self {
unk1: 0x14,
unk2: 0,
op_code: ServerChatIpcType::LoginReply,
option: 0,
2025-05-01 23:34:06 -04:00
timestamp: 0,
data: ServerChatIpcData::LoginReply {
timestamp: 0,
sid: 0,
},
}
}
}
#[binrw]
2025-06-26 21:06:54 -04:00
#[br(import(magic: &ServerChatIpcType))]
2025-05-01 23:34:06 -04:00
#[derive(Debug, Clone)]
pub enum ServerChatIpcData {
/// Sent by the server to Initialize something chat-related?
2025-06-26 21:06:54 -04:00
#[br(pre_assert(*magic == ServerChatIpcType::LoginReply))]
LoginReply {
timestamp: u32,
sid: u32,
},
Unknown,
2025-05-01 23:34:06 -04:00
}