1
This commit is contained in:
parent
aaa22350f4
commit
4f322d3cbd
@ -70,7 +70,12 @@ class PBTools {
|
||||
use std::cell::RefCell;
|
||||
use crate::cs::cs_proto as cs;
|
||||
|
||||
//static mut handlers [2000]Option<CsNetMsgHandler>
|
||||
struct Handler {
|
||||
msg_id: i32,
|
||||
handler_id: i32,
|
||||
}
|
||||
|
||||
static HANDLERS: Vec<Handler> = Vec::new();
|
||||
|
||||
/*
|
||||
func GetNetMsgHandler(msgId uint16) Option<CsNetMsgHandler> {
|
||||
@ -108,37 +113,33 @@ pub trait MsgHandler {`;
|
||||
|
||||
fn ${finalyName}(&self, _: &f9::MsgHdr, _: Rc::<RefCell::<cs::${item.name}>>) {
|
||||
panic!("not implement");
|
||||
}`;
|
||||
}
|
||||
`;
|
||||
}
|
||||
});
|
||||
data += `
|
||||
}
|
||||
`;
|
||||
/*
|
||||
data += `
|
||||
func init() {
|
||||
pub fn registe_handlers() {
|
||||
`;
|
||||
this.csProtoPb.nested.cs.nestedArray.forEach(
|
||||
(item) => {
|
||||
if (item.name[0] == 'C' &&
|
||||
item.name[1] == 'M') {
|
||||
/*
|
||||
data += `
|
||||
handlers[int(CMMessageIdE__${item.name})] = &CsNetMsgHandler{
|
||||
MsgId: int(CMMessageIdE__${item.name}),
|
||||
ParseCb: func (data []byte) interface{} {
|
||||
msg := &${item.name}{}
|
||||
proto.Unmarshal(data, msg)
|
||||
return msg
|
||||
},
|
||||
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||
handler.${item.name}(hdr, hdr.Msg.(*${item.name}))
|
||||
},
|
||||
}
|
||||
`;
|
||||
HANDLERS[int(CMMessageIdE__${item.name})] = &CsNetMsgHandler{
|
||||
MsgId: int(CMMessageIdE__${item.name}),
|
||||
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||
handler.${item.name}(hdr, hdr.Msg.(*${item.name}))
|
||||
},
|
||||
};
|
||||
`;*/
|
||||
}
|
||||
});
|
||||
data += `
|
||||
}`;*/
|
||||
}`;
|
||||
fs.writeFileSync('./src/cs/cs_auto_gen.rs', data);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user