1
This commit is contained in:
parent
19d957a62c
commit
99e2abfc68
@ -26,6 +26,85 @@ static void _GMOpsReload(f8::JsonHttpRequest* request)
|
||||
a8::UdpLog::Instance()->Warning("reload config files", {});
|
||||
}
|
||||
|
||||
static bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
||||
{
|
||||
const google::protobuf::Descriptor* descriptor = msg->GetDescriptor();
|
||||
const google::protobuf::Reflection* reflection = msg->GetReflection();
|
||||
|
||||
for (int i = 0; i < descriptor->field_count(); ++i) {
|
||||
const google::protobuf::FieldDescriptor* field_desc = descriptor->field(i);
|
||||
switch (field_desc->cpp_type()) {
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
|
||||
{
|
||||
#if 0
|
||||
reflection->SetString(msg, field_desc, reader.GetValue(field_name));
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
|
||||
{
|
||||
if (hdr.offset + sizeof(int) < hdr.buflen) {
|
||||
abort();
|
||||
}
|
||||
int* p_val = (int*)&hdr.buf[hdr.offset];
|
||||
reflection->SetInt32(msg, field_desc, *p_val);
|
||||
}
|
||||
break;
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
|
||||
{
|
||||
if (hdr.offset + sizeof(unsigned int) < hdr.buflen) {
|
||||
abort();
|
||||
}
|
||||
unsigned int* p_val = (unsigned int*)&hdr.buf[hdr.offset];
|
||||
reflection->SetUInt32(msg, field_desc, *p_val);
|
||||
}
|
||||
break;
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
|
||||
{
|
||||
if (hdr.offset + sizeof(long long) < hdr.buflen) {
|
||||
abort();
|
||||
}
|
||||
long long* p_val = (long long*)&hdr.buf[hdr.offset];
|
||||
reflection->SetInt64(msg, field_desc, *p_val);
|
||||
}
|
||||
break;
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
|
||||
{
|
||||
if (hdr.offset + sizeof(unsigned long long) < hdr.buflen) {
|
||||
abort();
|
||||
}
|
||||
unsigned long long* p_val = (unsigned long long*)&hdr.buf[hdr.offset];
|
||||
reflection->SetUInt64(msg, field_desc, *p_val);
|
||||
}
|
||||
break;
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
|
||||
{
|
||||
if (hdr.offset + sizeof(float) < hdr.buflen) {
|
||||
abort();
|
||||
}
|
||||
float* p_val = (float*)&hdr.buf[hdr.offset];
|
||||
reflection->SetFloat(msg, field_desc, *p_val);
|
||||
}
|
||||
break;
|
||||
case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
|
||||
{
|
||||
if (hdr.offset + sizeof(double) < hdr.buflen) {
|
||||
abort();
|
||||
}
|
||||
double* p_val = (double*)&hdr.buf[hdr.offset];
|
||||
reflection->SetFloat(msg, field_desc, *p_val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
abort();
|
||||
}
|
||||
break;
|
||||
}//end switch
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void HandlerMgr::Init()
|
||||
{
|
||||
RegisterNetMsgHandlers();
|
||||
@ -39,7 +118,7 @@ void HandlerMgr::UnInit()
|
||||
|
||||
void HandlerMgr::RegisterNetMsgHandlers()
|
||||
{
|
||||
RegisterNetMsgHandler(&gcmsghandler, &PlayerMgr::_CMAuthSession);
|
||||
RegisterNetMsgHandler(&gcmsghandler, &PlayerMgr::_CMAuthSession, CustomParser);
|
||||
}
|
||||
|
||||
void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle,
|
||||
|
Loading…
x
Reference in New Issue
Block a user