This commit is contained in:
azw 2023-11-02 01:08:25 +00:00
parent b6841bc20f
commit 06d7487868

View File

@ -74,7 +74,7 @@ use crate::cs::cs_msgid as cs_msgid;
pub struct Handler {
msg_id: i32,
handler_id: i32,
cb: Box::<dyn FnMut (&f9::MsgHdr, &dyn MsgHandler)>,
cb: Box::<dyn Fn (&f9::MsgHdr, &dyn MsgHandler)>,
}
static mut HANDLERS: Vec<Option<Handler>> = Vec::new();
@ -104,10 +104,22 @@ pub fn reg_handler_id(msg_id: u16, handler_id: i32){
}
}
/*
func DispatchMsg(handler *CsNetMsgHandler, hdr *f5.MsgHdr, msgHandler MsgHandler) {
handler.Cb(hdr, msgHandler)
pub fn dispatch_msg(msg_id: u16, hdr: &f9::MsgHdr, h: &dyn MsgHandler) {
let mut handler: &Option<Handler> = &None;
unsafe {
handler = get_net_msg_handler(msg_id);
}
match handler {
Some(v) => {
(*v.cb)(hdr, h);
}
None => {
}
}
}
/*
func ParsePb(msgId uint16, data []byte) interface{} {
handler := handlers[msgId]