This commit is contained in:
azw 2023-11-02 00:56:40 +00:00
parent 6df64c08ad
commit ef6df292e5

View File

@ -71,21 +71,23 @@ use std::cell::RefCell;
use crate::cs::cs_proto as cs;
use crate::cs::cs_msgid as cs_msgid;
struct Handler {
pub struct Handler {
msg_id: i32,
handler_id: i32,
cb: Box::<dyn FnMut (&f9::MsgHdr, &dyn MsgHandler)>,
}
static mut HANDLERS: Vec<Option<Handler>> = Vec::new();
//static HANDLERS: [Option<Handler>; 2000];
/*
func GetNetMsgHandler(msgId uint16) Option<CsNetMsgHandler> {
// handler := handlers[msgId]
// return handler
return None
}*/
pub fn get_net_msg_handler(msg_id: u16) -> &'static Option<Handler> {
unsafe {
if (msg_id as usize) < HANDLERS.len() {
return &HANDLERS[msg_id as usize];
} else {
return &None;
}
}
}
/*
func DispatchMsg(handler *CsNetMsgHandler, hdr *f5.MsgHdr, msgHandler MsgHandler) {